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 "";
	}

  

原文地址:https://www.cnblogs.com/otways/p/11452466.html