Package org.springframework.web.servlet
Interface LocaleContextResolver
- All Superinterfaces:
LocaleResolver
- All Known Implementing Classes:
AbstractLocaleContextResolver
,CookieLocaleResolver
,FixedLocaleResolver
,SessionLocaleResolver
Extension of
LocaleResolver
, adding support for a rich locale context
(potentially including locale and time zone information).- Since:
- 4.0
- Author:
- Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionresolveLocaleContext
(HttpServletRequest request) Resolve the current locale context via the given request.void
setLocaleContext
(HttpServletRequest request, HttpServletResponse response, LocaleContext localeContext) Set the current locale context to the given one, potentially including a locale with associated time zone information.Methods inherited from interface org.springframework.web.servlet.LocaleResolver
resolveLocale, setLocale
-
Method Details
-
resolveLocaleContext
Resolve the current locale context via the given request.This is primarily intended for framework-level processing; consider using
RequestContextUtils
orRequestContext
for application-level access to the current locale and/or time zone.The returned context may be a
TimeZoneAwareLocaleContext
, containing a locale with associated time zone information. Simply apply aninstanceof
check and downcast accordingly.Custom resolver implementations may also return extra settings in the returned context, which again can be accessed through downcasting.
- Parameters:
request
- the request to resolve the locale context for- Returns:
- the current locale context (never
null
- See Also:
-
setLocaleContext
void setLocaleContext(HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable LocaleContext localeContext) Set the current locale context to the given one, potentially including a locale with associated time zone information.- Parameters:
request
- the request to be used for locale modificationresponse
- the response to be used for locale modificationlocaleContext
- the new locale context, ornull
to clear the locale- Throws:
UnsupportedOperationException
- if the LocaleResolver implementation does not support dynamic changing of the locale or time zone- See Also:
-