用java.net的请进,一个关于用URL上传文件的问题.
用如下代码我实现了一个表单的提交,但是我如何做到用URL来提交一个enctype="MULTIPART/FORM-DATA" 的表单呢???
String sIP = r.getString("ServerIP");
String sPort = r.getString("ServerPort");
URL url = new URL("http://"+sIP+":"+sPort+"/corp/HttpMtServlet");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setDoOutput(true);
PrintWriter out = new PrintWriter(connection.getOutputStream());
out.println(strusername+"&"+strpasswd+"&"+strtonum+"&"+strtext+"&"+strpresendtime+"&"+strmoid+"&"+strfromnum+"&"+strpaynum+"&"+strserviceid+"&"+strfeetype+"&"+strfeeusertype+"&"+strfee+"&"+strformat);
out.close();