public interface

LocaleResolver

org.springframework.web.servlet.LocaleResolver
Known Indirect Subclasses

Class Overview

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.

Summary

Public Methods
abstract Locale resolveLocale(HttpServletRequest request)
Resolve the current locale via the given request.
abstract void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale)
Set the current locale to the given one.

Public Methods

public abstract Locale resolveLocale (HttpServletRequest request)

Resolve the current locale via the given request. Should return a default locale as fallback in any case.

Parameters
request the request to resolve the locale for
Returns
  • the current locale (never null)

public abstract void setLocale (HttpServletRequest request, HttpServletResponse response, 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 null to clear the locale
Throws
UnsupportedOperationException if the LocaleResolver implementation does not support dynamic changing of the theme