关于HttpClient中文乱码

HttpClient client = new HttpClient();

GetMethod get = new GetMethod(url);

try {

NameValuePair []data  = new NameValuePair[]{

new NameValuePair("test1",  "山东省"),

new NameValuePair("test2",  "dsd"),

new NameValuePair("test3", "1111"),

new NameValuePair("tesr4", "ceshi")

};

//中文乱码下面这句

get.setQueryString(EncodingUtil.formUrlEncode(data, "GBK"));

client.executeMethod(get);

//释放连接  

get.releaseConnection();

} catch (HttpException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

猜你喜欢

转载自ailongni.iteye.com/blog/1677941
今日推荐