注解
@GetMapping("/test/{id}/user/{userName}")
public void testPathVariable(@PathVariable("id") Integer id,
@PathVariable("userName") String userName,
@PathVariable Map<String,String> allPathVariable){
return;
}
@GetMapping("/test")
public void testHeader(@RequestHeader("User-Agent") String userAgent,
@RequestHeader Map<String,String> allHeader){
return;
}
- @RequestParam :获取请求头参数中的参数提供给指定参数使用
public String login(@RequestParam String userName,
@RequestParam("psw") String password,
){
- @CookieValue :获取Cookie的值
- @RequestAttribute :获取request域属性
@GetMapping("/goto")
public String gotoPage(HttpServletRequest httpServletRequest){
httpServletRequest.setAttribute("msg","这是我给success的消息");
httpServletRequest.setAttribute("code",200);
return "forward:/user/success";
}
@ResponseBody
@GetMapping("/success")
public void successPage(@RequestAttribute("msg") String msgFromGoto){
System.out.println("我从GOTO转发到这儿啦,他给我说:"+msgFromGoto);
}
- @RequestBody :获取请求体
- @MatrixVariable:矩阵变量