日期:2014-05-18  浏览次数:20711 次

java 实现http post multipart/form-data 如何实现! 谢谢了
用java程序如何实现下面的功能! 
注意 文件: <input type=file
<form action="http://127.0.0.1/mms_upload.asp" method="post" enctype="multipart/form-data">
账号: <input name=User value=""/><br/>
密码: <input name=Pass type="password" value=""/><br/>
文件: <input type=file name=file /><br/>
<input type=submit value="提交" />
</form>

------解决方案--------------------
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("xxx.xxx"))); 
ServletInputStream in = request.getInputStream(); 
int i = in.read(); 
while (i != -1) { 
pw.print((char) i); 
i = in.read(); 

pw.close();
...

------解决方案--------------------
apache有现成的接口:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/