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 for
LocaleContextResolver
implementations.
Provides support for a default locale and a default time zone.
Also provides pre-implemented versions of resolveLocale(jakarta.servlet.http.HttpServletRequest)
and setLocale(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, java.util.Locale)
,
delegating to LocaleContextResolver.resolveLocaleContext(jakarta.servlet.http.HttpServletRequest)
and LocaleContextResolver.setLocaleContext(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, org.springframework.context.i18n.LocaleContext)
.
- Since:
- 4.0
- Author:
- Juergen Hoeller
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturn the default TimeZone that this resolver is supposed to fall back to, if any.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 Details
-
AbstractLocaleContextResolver
public AbstractLocaleContextResolver()
-
-
Method Details
-
setDefaultTimeZone
Set a default TimeZone that this resolver will return if no other time zone found. -
getDefaultTimeZone
Return the default TimeZone that this resolver is supposed to fall back to, if any. -
resolveLocale
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, @Nullable HttpServletResponse response, @Nullable 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
-