- 统一添加接口返回结果处理 ResponseBodyAdvice切面操作返回值
- 统一添加接口参数输出日志,级别debug
1、ResponseBodyAdvice可以在注解@ResponseBody将返回值处理成相应格式之前操作返回值。实现这个接口即可完成相应操作。可用于返回值加密
实现相应类:ResponseBodyAdvice
源码如下:
public interface ResponseBodyAdvice<T>{
/**
* Whether this component supports the given controller method return type
* and the selected {@code HttpMessageConverter} type.(此组件是否支持给定的控制器方法返回值类型)
* @param returnType the return type(返回类型)
* @param converterType the selected converter type(选中的转换器类型)
* @return {@code true} if {@link #beforeBodyWrite} should be invoked;
* {@code false} otherwise(返回是否调用处理方法)
*/
boolean support(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType);
/**
* Invoked after an {@code HttpMessageConverter} is selected and just before
* its write