public interface LocaleContextResolver extends LocaleResolver
LocaleResolver
that adds support for a rich locale context
(potentially including locale and time zone information).LocaleContext
,
TimeZoneAwareLocaleContext
,
LocaleContextHolder
,
RequestContext.getTimeZone()
,
RequestContextUtils.getTimeZone(javax.servlet.http.HttpServletRequest)
Modifier and Type | Method and Description |
---|---|
LocaleContext |
resolveLocaleContext(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.
|
resolveLocale, setLocale
LocaleContext resolveLocaleContext(HttpServletRequest request)
This is primarily intended for framework-level processing; consider using
RequestContextUtils
or
RequestContext
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 an instanceof
check and downcast accordingly.
Custom resolver implementations may also return extra settings in the returned context, which again can be accessed through downcasting.
request
- the request to resolve the locale context fornull
LocaleResolver.resolveLocale(HttpServletRequest)
,
RequestContextUtils.getLocale(javax.servlet.http.HttpServletRequest)
,
RequestContextUtils.getTimeZone(javax.servlet.http.HttpServletRequest)
void setLocaleContext(HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable LocaleContext localeContext)
request
- the request to be used for locale modificationresponse
- the response to be used for locale modificationlocaleContext
- the new locale context, or null
to clear the localeUnsupportedOperationException
- if the LocaleResolver implementation
does not support dynamic changing of the locale or time zoneLocaleResolver.setLocale(HttpServletRequest, HttpServletResponse, Locale)
,
SimpleLocaleContext
,
SimpleTimeZoneAwareLocaleContext