您的位置:首页 > 理论基础 > 计算机网络

httpclient上传图片与参数,处理中文乱码

2013-10-30 17:32 477 查看
public static void main(String[] args) throws Exception {

String url="http://192.168.100.234:6888/aic/aicexi/commoncase/writ/WritUploadAction.jsp";

HttpClient client = new HttpClient();

PostMethod pos = new PostMethod(url);

File file=new File("C:/Users/Administrator/Desktop/psb.jpg");

Part[] part=new Part[]{new FilePart(file.getName(), file),new StringPart("JS@fsDescriptionInformation", "测试","GBK"),

new StringPart("JS@fdSentTime", "2013-10-24")};

pos.setRequestEntity(new MultipartRequestEntity(part,pos.getParams()));

client.executeMethod(pos);

System.out.println(pos.getResponseBodyAsStream());

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: