Class RequestLocaleHandler

java.lang.Object
org.apache.struts2.interceptor.i18n.AbstractLocaleHandler
org.apache.struts2.interceptor.i18n.RequestLocaleHandler
All Implemented Interfaces:
LocaleHandler
Direct Known Subclasses:
AcceptLanguageLocaleHandler

public abstract class RequestLocaleHandler extends AbstractLocaleHandler
Resolves locale from a request-only parameter (not persisted to session or cookie).

When a matching request parameter is present and the locale is supported, it is applied to the current request only; it is never stored for subsequent requests.

See Also:
  • Constructor Details

    • RequestLocaleHandler

      protected RequestLocaleHandler(ActionInvocation invocation, String requestOnlyParameterName)
  • Method Details

    • find

      public Locale find()
      Description copied from interface: LocaleHandler
      Looks for an explicit locale override in request-scoped sources.
      Returns:
      a locale override or null when no explicit override is present
    • findRequestOnlyParamLocale

      protected Locale findRequestOnlyParamLocale()
      Looks up the locale from the request-only parameter without any additional fallback. Subclasses that add fallback logic (e.g. Accept-Language) can override find() while stored-locale handlers can call this method directly to skip the fallback.
    • store

      public Locale store(ActionInvocation invocation, Locale locale)
      Description copied from interface: LocaleHandler
      Persists the resolved locale when storage is enabled for the current handler.
      Parameters:
      invocation - current action invocation
      locale - locale to store
      Returns:
      the effective locale to apply to the invocation context
    • read

      public Locale read(ActionInvocation invocation)
      Description copied from interface: LocaleHandler
      Reads locale from persistent/context sources when LocaleHandler.find() did not resolve one.
      Parameters:
      invocation - current action invocation
      Returns:
      resolved locale or null when no locale could be resolved