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

HTTPClient PostMethod 中文乱码处理

2014-02-11 10:33 459 查看
HttpClient client = new HttpClient();
PostMethod post=null;
String info="";
try {
post = new PostMethod("http://192.168.11.178/SMSCore/sendSMS.do");
NameValuePair[] postdata = new NameValuePair[4];
postdata[0] = new NameValuePair("telephone",this.receivers );
postdata[1] = new NameValuePair("message",this.content );
postdata[2] = new NameValuePair("system","console" );
postdata[3] = new NameValuePair("sysPassword","123");
post.addRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");//关键代码
post.addParameters(postdata);
int state = client.executeMethod(post);
String html=post.getResponseBodyAsString();
setAjax_out_data(new ByteArrayInputStream(html.getBytes("UTF-8")));
} catch (Exception e) {
e.printStackTrace();
}finally{
post.releaseConnection();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: