request请求获取请求体完整报文

private String getRequestBody(HttpServletRequest request) {
		try {
			InputStream v_inputstream = request.getInputStream();
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			int x = 0;
			while ((x = v_inputstream.read()) != -1) {
				baos.write(x);
			}
			baos.flush();
			return new String(baos.toByteArray(), UTF_8);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
		return "";
	}

  

posted @ 2019-09-03 13:37  oc-long  阅读(3218)  评论(0)    收藏  举报