https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc-ann-cookievalue
Web on Servlet Stack
Spring Web MVC is the original web framework built on the Servlet API and has been included in the Spring Framework from the very beginning. The formal name, “Spring Web MVC,” comes from the name of its source module (spring-webmvc), but it is more com
docs.spring.io
컨트롤러의 메소드에서 쿠키값을 바인딩할 수 있다.
@Slf4j
@RestController
public class CookieValueController {
// 쿠키 생성하기
@GetMapping("/createCookieValue")
public void createCookieValue(HttpServletResponse response) {
Cookie cookie = new Cookie("cookie", "HelloWorld");
response.addCookie(cookie);
}
// 쿠키값 읽기
@GetMapping("/cookieValue")
public void cookieValue(@CookieValue("cookie") String cookie) {
log.info("cookie : {}", cookie);
}
}
실행결과
Spring MVC @ModelAttribute (매개변수 레벨) (0) | 2022.05.25 |
---|---|
Spring MVC @RequestParam (0) | 2022.05.23 |
Spring MVC @RequestMapping - 요청받기 (0) | 2022.05.19 |
댓글 영역