类 LocaleChangeInterceptor

java.lang.Object
cn.taketoday.web.i18n.LocaleChangeInterceptor
所有已实现的接口:
HandlerInterceptor

public class LocaleChangeInterceptor extends Object implements HandlerInterceptor
Interceptor that allows for changing the current locale on every request, via a configurable request parameter (default parameter name: "locale").
从以下版本开始:
4.0
作者:
Juergen Hoeller, Rossen Stoyanchev, Harry Yang
另请参阅:
  • 字段详细资料

    • DEFAULT_PARAM_NAME

      public static final String DEFAULT_PARAM_NAME
      Default name of the locale specification parameter: "locale".
      另请参阅:
    • logger

      protected final cn.taketoday.logging.Logger logger
    • paramName

      private String paramName
    • httpMethods

      @Nullable private String[] httpMethods
    • ignoreInvalidLocale

      private boolean ignoreInvalidLocale
    • localeResolver

      @Nullable private LocaleResolver localeResolver
  • 构造器详细资料

    • LocaleChangeInterceptor

      public LocaleChangeInterceptor()
  • 方法详细资料

    • setParamName

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

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

      public void setHttpMethods(@Nullable String... httpMethods)
      Configure the HTTP method(s) over which the locale can be changed.
      参数:
      httpMethods - the methods
    • getHttpMethods

      @Nullable public String[] getHttpMethods()
      Return the configured HTTP methods.
    • setIgnoreInvalidLocale

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

      public boolean isIgnoreInvalidLocale()
      Return whether to ignore an invalid value for the locale parameter.
    • setLocaleResolver

      public void setLocaleResolver(@Nullable LocaleResolver localeResolver)
      Configure LocaleResolver
    • getLocaleResolver

      @Nullable public LocaleResolver getLocaleResolver()
      Return LocaleResolver.
    • beforeProcess

      public boolean beforeProcess(RequestContext request, Object handler)
      从接口复制的说明: HandlerInterceptor
      Before Handler process.
      指定者:
      beforeProcess 在接口中 HandlerInterceptor
      参数:
      request - Current request Context
      handler - Request handler , HandlerMethod
      返回:
      If is it possible to execute the target handler
      另请参阅:
    • checkHttpMethod

      private boolean checkHttpMethod(String currentMethod)
    • parseLocaleValue

      @Nullable protected Locale parseLocaleValue(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.

      参数:
      localeValue - the locale value to parse
      返回:
      the corresponding Locale instance