3个地方设置编码,解决乱码问题
public static String GetResponse(HttpMethodBase Method) throws IOException { 然后在构建GetMethod或PostMethod时也指定编码 Method.addRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");//3 或者 NameValuePair p2 = new NameValuePair( "Content-Type","text/html; charset=utf-8"); post.setRequestBody( new NameValuePair[]{p2})//3 |
|
来自: moonboat > 《Jakarta Commons》