第一种:
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"));//在设置请求数据的时候,指定编码。