[SpringBoot2]请求处理_@RequestAttribute
Posted 唐火
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[SpringBoot2]请求处理_@RequestAttribute相关的知识,希望对你有一定的参考价值。
@Controller
public class RequestController
@GetMapping("/goto")
public String gotoPage(HttpServletRequest request)
request.setAttribute("msg","success");
request.setAttribute("code",200);
return "forward:/success";
@ResponseBody
@GetMapping("/success")
public Map success(@RequestAttribute("msg") String msg, @RequestAttribute("code") Integer code, HttpServletRequest request)
Object msg1 = request.getAttribute("msg");
Map<String ,Object> map = new HashMap<>();
map.put("reqMethod_msg",msg1);
map.put("annotation_msg",msg);
return map;
可以看到两种方式都可以取到存在域中的值!
以上是关于[SpringBoot2]请求处理_@RequestAttribute的主要内容,如果未能解决你的问题,请参考以下文章
Springboot2之静态资源规则与定制化welcome与favicon功能Rest映射及源码解析以及改变默认的_method
Springboot2之静态资源规则与定制化welcome与favicon功能Rest映射及源码解析以及改变默认的_method
SpringBoot2之web开发(上)——之静态资源和请求参数处理