httpclient 4.2.1 文件上傳中文、文件名中文亂碼,
A HttpPost方式
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, Charset.forName("UTF-8"));
FileBody bin = new FileBody(new File(localFile));
StringBody userName = new StringBody("張三", ContentType.create("text/plain", Consts.UTF_8));
reqEntity.addPart("file", bin);
reqEntity.addPart("userName ", userName );
httpPost.setEntity(reqEntity);
B PostMethod方式
PostMethod postMethod = new PostMethod(url);
postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");