RequestBodyAdvice和ResponseBodyAdvice是干什么的

RequestBodyAdvice和ResponseBodyAdvice

有两个接口

RequestBodyAdviceResponseBodyAdvice 在spring4中新添加的两个接口

RequestBodyAdvice接口

该接口是在获取@RequestBody参数数据之前进行处理的

public interface RequestBodyAdvice {

   
   boolean supports(MethodParameter methodParameter, Type targetType,
         Class<? extends HttpMessageConverter<?>> converterType)
;

   
   Object handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter,
         Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
;

   
   HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter,
         Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
 throws IOException
;

   
   Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter,
         Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
;

}

ResponseBodyAdvice接口

该接口是在消息体被HttpMessageConverter消息解析器写入之前执行的

public interface ResponseBodyAdvice<T{

   
   boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType);

   
   beforeBodyWrite(T body, MethodParameter returnType, MediaType selectedContentType,
         Class<? extends HttpMessageConverter<?>> selectedConverterType,
         ServerHttpRequest request, ServerHttpResponse response)
;

}

https://zhhll.icu/2021/框架/springmvc/基础/11.RequestBodyAdvice和ResponseBodyAdvice/

本文由 mdnice 多平台发布

相关推荐

  1. RequestBodyAdviceResponseBodyAdvice干什么

    2024-05-26 04:44:26       11 阅读
  2. csv编辑器干什么

    2024-05-26 04:44:26       20 阅读
  3. git branch 干什么

    2024-05-26 04:44:26       18 阅读
  4. vueaxios干什么

    2024-05-26 04:44:26       21 阅读
  5. iosapp网站干什么呢?

    2024-05-26 04:44:26       34 阅读
  6. 大数据分析岗干什么

    2024-05-26 04:44:26       33 阅读
  7. MyBatis中MapperScan作用干什么

    2024-05-26 04:44:26       52 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-05-26 04:44:26       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-05-26 04:44:26       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-05-26 04:44:26       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-05-26 04:44:26       20 阅读

热门阅读

  1. HTML5 游戏开发基础及流程

    2024-05-26 04:44:26       11 阅读
  2. Unity vscode在mac上的编译环境设置

    2024-05-26 04:44:26       13 阅读
  3. 算法设计与分析-回溯法

    2024-05-26 04:44:26       12 阅读
  4. TLS/SSL握手协议

    2024-05-26 04:44:26       9 阅读
  5. RabbitMQ

    RabbitMQ

    2024-05-26 04:44:26      11 阅读
  6. RabbitMQ02-RebbitMQ简介及交换器

    2024-05-26 04:44:26       11 阅读
  7. 19_文件系统的制作 -YAFFS2

    2024-05-26 04:44:26       12 阅读