接口 LocaleContextResolver
- 所有超级接口:
LocaleResolver
- 所有已知实现类:
AbstractLocaleContextResolver,CookieLocaleResolver,FixedLocaleResolver,SessionLocaleResolver
public interface LocaleContextResolver extends LocaleResolver
Extension ofLocaleResolver, adding support for a rich locale context (potentially including locale and time zone information).- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller
- 另请参阅:
LocaleContext,TimeZoneAwareLocaleContext,LocaleContextHolder,RequestContext.getTimeZone(),RequestContextUtils.getTimeZone(javax.servlet.http.HttpServletRequest)
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 LocaleContextresolveLocaleContext(HttpServletRequest request)Resolve the current locale context via the given request.voidsetLocaleContext(HttpServletRequest request, HttpServletResponse response, LocaleContext localeContext)Set the current locale context to the given one, potentially including a locale with associated time zone information.从接口继承的方法 org.springframework.web.servlet.LocaleResolver
resolveLocale, setLocale
方法详细资料
resolveLocaleContext
LocaleContext resolveLocaleContext(HttpServletRequest request)
Resolve the current locale context via the given request.This is primarily intended for framework-level processing; consider using
RequestContextUtilsorRequestContextfor 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 aninstanceofcheck 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 for- 返回:
- the current locale context (never
null - 另请参阅:
LocaleResolver.resolveLocale(HttpServletRequest),RequestContextUtils.getLocale(javax.servlet.http.HttpServletRequest),RequestContextUtils.getTimeZone(javax.servlet.http.HttpServletRequest)
setLocaleContext
void setLocaleContext(HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable LocaleContext localeContext)
Set the current locale context to the given one, potentially including a locale with associated time zone information.- 参数:
request- the request to be used for locale modificationresponse- the response to be used for locale modificationlocaleContext- the new locale context, ornullto clear the locale- 抛出:
UnsupportedOperationException- if the LocaleResolver implementation does not support dynamic changing of the locale or time zone- 另请参阅:
LocaleResolver.setLocale(HttpServletRequest, HttpServletResponse, Locale),SimpleLocaleContext,SimpleTimeZoneAwareLocaleContext