|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.servlet.i18n.CookieLocaleResolver
Implementation of LocaleResolver that uses a cookie sent back to the user in case of a custom setting, with a fallback to the accept header locale. This is especially useful for stateless applications without user sessions.
Custom controllers can thus override the user's locale by calling setLocale, e.g. responding to a certain locale change request.
Field Summary | |
static int |
DEFAULT_COOKIE_MAX_AGE
|
static java.lang.String |
DEFAULT_COOKIE_NAME
|
static java.lang.String |
DEFAULT_COOKIE_PATH
|
static java.lang.String |
LOCALE_REQUEST_ATTRIBUTE_NAME
Name of the request attribute that holds the locale. |
Constructor Summary | |
CookieLocaleResolver()
|
Method Summary | |
int |
getCookieMaxAge()
|
java.lang.String |
getCookieName()
|
java.lang.String |
getCookiePath()
Use the given path for theme cookies. |
java.util.Locale |
resolveLocale(javax.servlet.http.HttpServletRequest request)
Resolve the current locale via the given request. |
void |
setCookieMaxAge(int cookieMaxAge)
Use the given maximum age, specified in seconds, for locale cookies. |
void |
setCookieName(java.lang.String cookieName)
Use the given name for locale cookies. |
void |
setCookiePath(java.lang.String cookiePath)
|
void |
setLocale(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.util.Locale locale)
Set the current locale to the given one. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String LOCALE_REQUEST_ATTRIBUTE_NAME
RequestContext.getLocale()
public static final java.lang.String DEFAULT_COOKIE_NAME
public static final java.lang.String DEFAULT_COOKIE_PATH
public static final int DEFAULT_COOKIE_MAX_AGE
Constructor Detail |
public CookieLocaleResolver()
Method Detail |
public void setCookieName(java.lang.String cookieName)
public java.lang.String getCookieName()
public java.lang.String getCookiePath()
public void setCookiePath(java.lang.String cookiePath)
public void setCookieMaxAge(int cookieMaxAge)
public int getCookieMaxAge()
public java.util.Locale resolveLocale(javax.servlet.http.HttpServletRequest request)
LocaleResolver
resolveLocale
in interface LocaleResolver
request
- request to be used for resolution
public void setLocale(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.Locale locale)
LocaleResolver
setLocale
in interface LocaleResolver
request
- request to be used for locale modificationresponse
- response to be used for locale modificationlocale
- the new locale
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |