Class AbstractLocaleContextResolver
- java.lang.Object
- org.springframework.web.servlet.i18n.AbstractLocaleResolver
- org.springframework.web.servlet.i18n.AbstractLocaleContextResolver
- All Implemented Interfaces:
LocaleContextResolver
,LocaleResolver
- Direct Known Subclasses:
FixedLocaleResolver
,SessionLocaleResolver
public abstract class AbstractLocaleContextResolver extends AbstractLocaleResolver implements LocaleContextResolver
Abstract base class forLocaleContextResolver
implementations. Provides support for a default locale and a default time zone.Also provides pre-implemented versions of
resolveLocale(javax.servlet.http.HttpServletRequest)
andsetLocale(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.util.Locale)
, delegating toLocaleContextResolver.resolveLocaleContext(javax.servlet.http.HttpServletRequest)
andLocaleContextResolver.setLocaleContext(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.springframework.context.i18n.LocaleContext)
.- Since:
- 4.0
- Author:
- Juergen Hoeller
- See Also:
AbstractLocaleResolver.setDefaultLocale(java.util.Locale)
,setDefaultTimeZone(java.util.TimeZone)
Constructor Summary
Constructors Constructor Description AbstractLocaleContextResolver()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TimeZone
getDefaultTimeZone()
Return the default TimeZone that this resolver is supposed to fall back to, if any.Locale
resolveLocale(HttpServletRequest request)
Resolve the current locale via the given request.void
setDefaultTimeZone(TimeZone defaultTimeZone)
Set a default TimeZone that this resolver will return if no other time zone found.void
setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale)
Set the current locale to the given one.Methods inherited from class org.springframework.web.servlet.i18n.AbstractLocaleResolver
getDefaultLocale, setDefaultLocale
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.servlet.LocaleContextResolver
resolveLocaleContext, setLocaleContext
Constructor Detail
AbstractLocaleContextResolver
public AbstractLocaleContextResolver()
Method Detail
setDefaultTimeZone
public void setDefaultTimeZone(TimeZone defaultTimeZone)
Set a default TimeZone that this resolver will return if no other time zone found.
getDefaultTimeZone
public TimeZone getDefaultTimeZone()
Return the default TimeZone that this resolver is supposed to fall back to, if any.
resolveLocale
public Locale resolveLocale(HttpServletRequest request)
Description copied from interface:LocaleResolver
Resolve the current locale via the given request. Can return a default locale as fallback in any case.- Specified by:
resolveLocale
in interfaceLocaleResolver
- Parameters:
request
- the request to resolve the locale for- Returns:
- the current locale (never
null
)
setLocale
public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale)
Description copied from interface:LocaleResolver
Set the current locale to the given one.- Specified by:
setLocale
in interfaceLocaleResolver
- Parameters:
request
- the request to be used for locale modificationresponse
- the response to be used for locale modificationlocale
- the new locale, ornull
to clear the locale