/** * request转字符串 * @param request * @param charset 编码格式 (UTF-8) * @return * @see [类、类#方法、类#成员] */ public static String parseRequst(HttpServletRequest request,String charset){ String body = ""; try { ServletInputStream inputStream = request.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(inputStream,charset)); while(true){ String info = br.readLine(); if(info == null){ break; } if(body == null || "".equals(body)){ body = info; }else{ body += info; } } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return body; }
标签:HttpServletRequest,body,中文,String,charset,request,info From: https://www.cnblogs.com/RedOrange/p/17091608.html