POST中文转码问题-创新互联
//在 new StringEntity(params, "utf-8")指定为utf-8编码
try {
HttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
//设置编码,防止中文传输乱码
StringEntity entity = new StringEntity(contentValue.toString(), "utf-8");
httpPost.setEntity(entity);
HttpResponse response = client.execute(httpPost);
//获取响应码
status = response.getStatusLine().getStatusCode();
//status = response.getStatusLine().getStatusCode();
Log.v("jsondata", "resp = " + response.getEntity().toString());
Log.v("jsondata", "status = " + status + "\n" + contentValue.toString());
}catch(Exception e){
Log.v("jsondata", "exception");
e.printStackTrace();
}创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。

网页名称:POST中文转码问题-创新互联
本文URL:http://www.scyingshan.cn/article/dhijpd.html


咨询
建站咨询
