Loading...
Spring Framework Reference Documentation 7.0.2의 @CookieValue의 한국어 번역본입니다.
아래의 경우에 피드백에서 신고해주신다면 반영하겠습니다.
감사합니다 :)
@CookieValueController에서 메서드 argument에 HTTP cookie의 값을 바인딩하기 위해 @CookieValue 어노테이션을 사용할 수 있습니다.
다음과 같은 cookie가 있는 요청을 가정해 보겠습니다:
1JSESSIONID=415A4AC178C59DACE0B2C9CA727CDD84
다음 예제는 cookie 값을 가져오는 방법을 보여줍니다:
1@GetMapping("/demo") 2public void handle(@CookieValue("JSESSIONID") String cookie) { (1) 3 //... 4} 5// Copied!
| 1 | JSESSIONID cookie의 값을 가져옵니다. |
1@GetMapping("/demo") 2fun handle(@CookieValue("JSESSIONID") cookie: String) { (1) 3 //... 4} 5// Copied!
| 1 | JSESSIONID cookie의 값을 가져옵니다. |
Target 메서드 parameter 타입이 String이 아닌 경우, 타입 변환이 자동으로 적용됩니다.
타입 변환을 참고하세요.
@RequestHeader
@ModelAttribute