This interface allows for implementations based on request, session,
cookies, etc. The default implementation is
org.,
simply using the request's locale provided by the respective HTTP header.
Use org.
to retrieve the current locale in controllers or views, independent
of the actual resolution strategy.
Note
As of Spring 4.0, there is an extended strategy interface
called LocaleContextResolver, allowing for resolution of
a org. object,
potentially including associated time zone information. Spring's
provided resolver implementations implement the extended
LocaleContextResolver interface wherever appropriate.
LocaleContextResolver, org.springframework.context.i18n.LocaleContextHolder , org.springframework.web.servlet.support.RequestContext#getLocale , org.springframework.web.servlet.support.RequestContextUtils#getLocale
| Modifier and Type | Method and Description |
|---|---|
| public Locale | Returns: the current locale (nevernull)the request to resolve the locale for request)Resolve the current locale via the given request. |
| public void | setLocale(HttpServletRequest
the request to be used for locale modification request, HttpServletResponse the response to be used for locale modification response, Locale the new locale, or locale)null to clear the localeSet the current locale to the given one. |
| resolveLocale | back to summary |
|---|---|
| public Locale resolveLocale(HttpServletRequest request) Resolve the current locale via the given request. Can return a default locale as fallback in any case.
| |
| setLocale | back to summary |
|---|---|
| public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) Set the current locale to the given one.
| |