HttpClient post提交請求亂碼問題解決
第一種:
HttpPost post=new HttpPost(url);
StringEntity content=new StringEntity(data, Charset.forName("utf-8"));// 設置編碼
content.setContentType("application/json; charset=UTF-8");
content.setContentEncoding("utf-8");
post.setEntity(content);
第二種:
httpPost.setEntity(new UrlEncodedFormEntity(nvps,"utf-8"));//在設置請求數據的時候,指定編碼。