Package org.springframework.web.servlet
Interface LocaleResolver
- All Known Subinterfaces:
- LocaleContextResolver
- All Known Implementing Classes:
- AbstractLocaleContextResolver,- AbstractLocaleResolver,- AcceptHeaderLocaleResolver,- CookieLocaleResolver,- FixedLocaleResolver,- SessionLocaleResolver
public interface LocaleResolver
Interface for web-based locale resolution strategies that allows for
 both locale resolution via the request and locale modification via
 request and response.
 
This interface allows for implementations based on request, session,
 cookies, etc. The default implementation is
 AcceptHeaderLocaleResolver,
 simply using the request's locale provided by the respective HTTP header.
 
Use RequestContext.getLocale()
 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 LocaleContext object,
 potentially including associated time zone information. Spring's
 provided resolver implementations implement the extended
 LocaleContextResolver interface wherever appropriate.
- Since:
- 27.02.2003
- Author:
- Juergen Hoeller
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionresolveLocale(HttpServletRequest request) Resolve the current locale via the given request.voidsetLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) Set the current locale to the given one.
- 
Method Details- 
resolveLocaleResolve the current locale via the given request.Can return a default locale as fallback in any case. - Parameters:
- request- the request to resolve the locale for
- Returns:
- the current locale (never null)
 
- 
setLocalevoid setLocale(HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable Locale locale) Set the current locale to the given one.- Parameters:
- request- the request to be used for locale modification
- response- the response to be used for locale modification
- locale- the new locale, or- nullto clear the locale
- Throws:
- UnsupportedOperationException- if the LocaleResolver implementation does not support dynamic changing of the locale
 
 
-