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

restful httpclient request中文乱码解决办法

2015-10-08 16:18 405 查看
public static String getPostJson(HttpServletRequest request){
String s = "";
try{
request.setCharacterEncoding("UTF-8");
ServletInputStream in = request.getInputStream();
int len = request.getContentLength();
if (len <= 0) {
return "";
}
byte[] buffer = new byte[len];
in.read(buffer);
s = new String(buffer,"UTF-8");
}catch(Exception re){
re.printStackTrace();
}
return s;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  restful httpclient r