PostMethod filePost = new PostMethod(TARGET);
Part[] parts=new Part[]{
new FilePart( "arg1 ",new ByteArrayPartSource(item.getName(),item.get())),
new StringPart( "arg2 ", "something "),
new StringPart( "arg3 ", "something "),
new StringPart( "arg3 ", "something "),
};
MultipartRequestEntity mre=new MultipartRequestEntity(parts,filePost.getParams());
filePost.setRequestEntity(mre);
HttpClient hc=new HttpClient();
int res=hc.executeMethod(filePost);
以上是我用HttpClient3.1上传文件的代码,在上传文件的同时还提交了几个普通字段。现在的问题是,文件可以上传成功,但是普通字段没有提交上去。这是为什么??(接收方是一个asp)
------解决方案--------------------
同样遇到这个问题,求解!