org.springframework.web.servlet.i18n

Class LocaleChangeInterceptor

    • Field Detail

      • DEFAULT_PARAM_NAME

        public static final java.lang.String DEFAULT_PARAM_NAME
        Default name of the locale specification parameter: "locale".
        See Also:
        Constant Field Values
      • logger

        protected final Log logger
    • Constructor Detail

      • LocaleChangeInterceptor

        public LocaleChangeInterceptor()
    • Method Detail

      • setParamName

        public void setParamName(java.lang.String paramName)
        Set the name of the parameter that contains a locale specification in a locale change request. Default is "locale".
      • getParamName

        public java.lang.String getParamName()
        Return the name of the parameter that contains a locale specification in a locale change request.
      • setHttpMethods

        public void setHttpMethods(@Nullable
                                   java.lang.String... httpMethods)
        Configure the HTTP method(s) over which the locale can be changed.
        Parameters:
        httpMethods - the methods
        Since:
        4.2
      • getHttpMethods

        @Nullable
        public java.lang.String[] getHttpMethods()
        Return the configured HTTP methods.
        Since:
        4.2
      • setIgnoreInvalidLocale

        public void setIgnoreInvalidLocale(boolean ignoreInvalidLocale)
        Set whether to ignore an invalid value for the locale parameter.
        Since:
        4.2.2
      • isIgnoreInvalidLocale

        public boolean isIgnoreInvalidLocale()
        Return whether to ignore an invalid value for the locale parameter.
        Since:
        4.2.2
      • setLanguageTagCompliant

        @Deprecated
        public void setLanguageTagCompliant(boolean languageTagCompliant)
        Deprecated. as of 5.1 since it only accepts true now
        Specify whether to parse request parameter values as BCP 47 language tags instead of Java's legacy locale specification format.

        NOTE: As of 5.1, this resolver leniently accepts the legacy Locale.toString() format as well as BCP 47 language tags.

        Since:
        4.3
        See Also:
        Locale.forLanguageTag(String), Locale.toLanguageTag()
      • isLanguageTagCompliant

        @Deprecated
        public boolean isLanguageTagCompliant()
        Deprecated. as of 5.1 since it always returns true now
        Return whether to use BCP 47 language tags instead of Java's legacy locale specification format.
        Since:
        4.3
      • parseLocaleValue

        @Nullable
        protected java.util.Locale parseLocaleValue(java.lang.String localeValue)
        Parse the given locale value as coming from a request parameter.

        The default implementation calls StringUtils.parseLocale(String), accepting the Locale.toString() format as well as BCP 47 language tags.

        Parameters:
        localeValue - the locale value to parse
        Returns:
        the corresponding Locale instance
        Since:
        4.3