java request.getInputStream中文乱码解决方案
请求时要指定为UTF-8,中文码码完美解决
/** * * 得到请求body字符串,一般用于content-type:application/json * */ public static String getBodyString(HttpServletRequest request) { StringBuilder buffer = new StringBuilder(""); try{ request.setCharacterEncoding("UTF-8"); BufferedReader reader=null; reader = new BufferedReader(new InputStreamReader(request.getInputStream(),"UTF-8")); String line=null; while((line = reader.readLine())!=null){ buffer.append(line); } }catch (IOException e) { LogerHelper.WebLog(e); } return buffer.toString(); }
欢迎加入JAVA技术交流QQ群:179945282
欢迎加入ASP.NET(C#)交流QQ群:17534377