使用@CookieValue可让处理方法入参绑定某个Cookie值
@Controller
@RequestMapping("/springmvc")
public class HelloWorld {
@RequestMapping(value = "/helloworld")
public String testRequestHeader(@CookieValue("JSESSIONID") String sessionID) {
System.out.println("test: " + sessionID);
return "success";
}
}
// 请求的URL
<a href="/springmvc/helloworld">TestCookie</a>