1,请求参数的打印
@ControllerAdvice(basePackages = "控制器的命名空间")
public class LogRequestAdvice implements RequestBodyAdvice {
Logger logger = LoggerFactory.getLogger(getClass());
@Override
public boolean supports(MethodParameter methodParameter, Type type, Class extends HttpMessageConverter>> aClass) {
//判断是否有此注解
boolean b = methodParameter.getParameterAnnotation(RequestBody.class) != null;
//只有为true时才会执行afterBodyRead
return b;
}
@Override
public HttpInputMessage beforeBodyRead(HttpInputMessage httpInputMessage, MethodParameter methodParameter, Type type, Class extends HttpMessageConverter>> aClass) throws IOException {
InputStream body = httpInputMessage.getBody();
return new MappingJacksonInputMessage(httpInputMessage.getBody(), httpInputMessage.getHeade