httpclient3解决post中文乱码
1.设置属性,以支持中文post数据
postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
扩展PostMethod类,以支持中文post数据。
代码如下
//PostMethod for UTF-8 support
public static class UTF8PostMethod extends PostMethod{
public UTF8PostMethod(String url){
super(url);
}
@Override
public String getRequestCharSet() {
//return super.getRequestCharSet();
return "UTF-8";
}
}
参考: