From e93bf49268cf808354d328dc99d87520356a8821 Mon Sep 17 00:00:00 2001 From: Mark Pollack Date: Tue, 31 Mar 2009 17:57:52 +0000 Subject: [PATCH] Add Michael Isvy's documentation on @CookieValue and @RequestHeader annotations. --- spring-framework-reference/src/mvc.xml | 46 +++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml index 65dde35be29..5c3369b49d5 100644 --- a/spring-framework-reference/src/mvc.xml +++ b/spring-framework-reference/src/mvc.xml @@ -282,7 +282,7 @@ DispatcherServlet declaration and mapping can be found below. - <web-app> + <web-app> <servlet> <servlet-name>example</servlet-name> @@ -3232,6 +3232,50 @@ public class EditPetForm { } +
+ Mapping cookie values with the @CookieValue annotation + + The @CookieValue annotation allows a method parameter to be bound to the value of an HTTP cookie. + + + Let us consider that the following cookie has been received with an http request: + JSESSIONID=415A4AC178C59DACE0B2C9CA727CDD84 + The following code sample allows you to easily get the value of the "JSESSIONID"cookie: + @RequestMapping("/displayHeaderInfo.do") +public void displayHeaderInfo(@CookieValue("JSESSIONID") String cookie) { + + //... + +} + This annotation is supported for annotated handler methods in Servlet and Portlet environments. +
+ +
+ Mapping request header attributes with the @RequestHeader annotation + + The @RequestHeader annotation allows a method parameter to be bound to a request header. + + + Here is a request header sample: + + The following code sample allows you to easily get the value of the "Accept-Encoding" and "Keep-Alive" headers: + @RequestMapping("/displayHeaderInfo.do") + public void displayHeaderInfo(@RequestHeader("Accept-Encoding") String encoding, + @RequestHeader("Keep-Alive") long keepAlive) { + + //... + +} + This annotation is supported for annotated handler methods in Servlet and Portlet environments. +
+
Customizing <classname>WebDataBinder</classname>