httpclient 请求 post、get

如果PostMethod提交的是中文字符,需要加上相应的编码格式:
post.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=gbk");

如果GetMethod提交的参数有中文字符,需要先转换成utf-8格式:
URLEncoder.encode("杭州", "utf-8");

猜你喜欢

转载自it1990eye0920.iteye.com/blog/2223372