我['M目前使用這樣的事情httpURLConnection:post參數可以多久?
HttpURLConnection con = (HttpURLConnection) u.openConnection();
con.setDoInput(true);
con.setRequestMethod("POST");
con.setDoInput (true);
con.setDoOutput (true);
con.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
out = new DataOutputStream(con.getOutputStream());
String content = "username=" + URLEncoder.encode ("bob")
+ "&password=" + URLEncoder.encode ("smith");
System.out.println("\n" + "sending form to HTTP server ...");
out.writeBytes (content);
out.flush();
out.close();
con.connect();
有了這個,我管理的一些數據傳遞到我的服務器。我現在徘徊的是多少可以這樣發送?
我想能夠發送一些xml文件(100〜200行長),並想知道我是否可以做到這一點?
Jason
你實際上應該使用`multipart/form-data`編碼。另請參閱http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests – BalusC 2011-01-24 12:15:36