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
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.
-
Field Summary
Fields inherited from class org.apache.struts2.interceptor.i18n.AbstractLocaleHandler
actionInvocation -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRequestLocaleHandler(ActionInvocation invocation, String requestOnlyParameterName) -
Method Summary
Modifier and TypeMethodDescriptionfind()Looks for an explicit locale override in request-scoped sources.protected LocaleLooks up the locale from the request-only parameter without any additional fallback.read(ActionInvocation invocation) Reads locale from persistent/context sources whenLocaleHandler.find()did not resolve one.store(ActionInvocation invocation, Locale locale) Persists the resolved locale when storage is enabled for the current handler.Methods inherited from class org.apache.struts2.interceptor.i18n.AbstractLocaleHandler
disableStore, findLocaleParameter, getLocaleFromParam, isLocaleSupported, shouldStore
-
Constructor Details
-
RequestLocaleHandler
-
-
Method Details
-
find
Description copied from interface:LocaleHandlerLooks for an explicit locale override in request-scoped sources.- Returns:
- a locale override or
nullwhen no explicit override is present
-
findRequestOnlyParamLocale
Looks up the locale from the request-only parameter without any additional fallback. Subclasses that add fallback logic (e.g. Accept-Language) can overridefind()while stored-locale handlers can call this method directly to skip the fallback. -
store
Description copied from interface:LocaleHandlerPersists the resolved locale when storage is enabled for the current handler.- Parameters:
invocation- current action invocationlocale- locale to store- Returns:
- the effective locale to apply to the invocation context
-
read
Description copied from interface:LocaleHandlerReads locale from persistent/context sources whenLocaleHandler.find()did not resolve one.- Parameters:
invocation- current action invocation- Returns:
- resolved locale or
nullwhen no locale could be resolved
-