We use a CookieLocaleResolver in the following example:
<bean id="localeResolver" class="org.springframework.web.servlet. i18n.CookieLocaleResolver"> <property name="defaultLocale" value="en" /> <property name="cookieName" value="userLocaleCookie"/> <property name="cookieMaxAge" value="7200"/> </bean>
Important things to note are as follows:
- <property name="cookieName" value="userLocaleCookie"/>: The name of the cookie stored in the browser will be userLocaleCookie.
- <property name="cookieMaxAge" value="7200"/>: The lifetime of the cookie is 2 hours (7200 seconds).
- Since we are using LocaleChangeInterceptor from the previous example, if you append language=en to any URL, you would be using en locale ...