Class AcceptHeaderLocaleContextResolver

  • java.lang.Object
    • org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver
    • Constructor Detail

      • AcceptHeaderLocaleContextResolver

        public AcceptHeaderLocaleContextResolver()
    • Method Detail

      • setSupportedLocales

        public void setSupportedLocales(java.util.List<java.util.Locale> locales)
        Configure supported locales to check against the requested locales determined via HttpHeaders.getAcceptLanguageAsLocales().
        locales - the supported locales
      • getSupportedLocales

        public java.util.List<java.util.Locale> getSupportedLocales()
        Return the configured list of supported locales.
      • setDefaultLocale

        public void setDefaultLocale(@Nullable
                                     java.util.Locale defaultLocale)
        Configure a fixed default locale to fall back on if the request does not have an "Accept-Language" header (not set by default).
        defaultLocale - the default locale to use
      • getDefaultLocale

        public java.util.Locale getDefaultLocale()
        The configured default locale, if any.
      • resolveLocaleContext

        public LocaleContext resolveLocaleContext(ServerWebExchange exchange)
        Description copied from interface: LocaleContextResolver
        Resolve the current locale context via the given exchange.

        The returned context may be a TimeZoneAwareLocaleContext, containing a locale with associated time zone information. Simply apply an instanceof check and downcast accordingly.

        Custom resolver implementations may also return extra settings in the returned context, which again can be accessed through downcasting.

        Specified by:
        resolveLocaleContext in interface LocaleContextResolver
        exchange - current server exchange
        the current locale context (never null)