方法如下:
代码语言:javascript复制 try{
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = requestAttributes.getRequest();
StringBuffer sb = new StringBuffer() ;
InputStream is = request.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String s = "" ;
while((s=br.readLine())!=null){
sb.append(s) ;
}
String result =sb.toString();
log.info("nn ----------- 请求 json 为 :" result);
}catch (Exception e){
...
}