工作中遇到spring mvc 不通controller之间接口的post请求转发,特此记录下:
1、controller类上必须要用@Controller注解
2、转发controller中需要转发的接口使用Model、ModelAndView或者HttpServletRequest存储==>使用@RequestBody Post请求携带的参数。
3、目标controller中目标接口使用@RequestAttribute注解获取同名称的转发接口请求的参数。(重点:因为使用Model等携带参数的实体,会把该请求参数放到request attribute中,所以下游接口需要从request attribute中获取,而不是原有的request body)
spring mvc controller之间post请求转发
最新推荐文章于 2024-05-19 09:58:12 发布