public String getMessage(HttpServletRequest request) { ServletInputStream servletInputStream = null; InputStreamReader inputStreamReader = null; BufferedReader reader = null; StringBuffer buffer = new StringBuffer(); try { servletInputStream = (ServletInputStream) request.getInputStream(); inputStreamReader = new InputStreamReader(servletInputStream, "utf-8"); reader = new BufferedReader(inputStreamReader); String temp; while ((temp = reader.readLine()) != null) { buffer.append(temp); } } catch (IOException e) { logger.error(e.getMessage(), e); } finally { try { if (reader != null) { reader.close(); } if (inputStreamReader != null) { inputStreamReader.close(); } if (servletInputStream != null) { servletInputStream.close(); } } catch (Exception e) { logger.error(e.getMessage(), e); } } logger.debug("报文内容 = " + buffer.toString()); return buffer.toString(); }
HttpServletRequest 接收参数处理
最新推荐文章于 2023-01-14 08:55:37 发布