Note that there are some explanatory texts on larger screens.

plurals
  1. POStruts2 localize interceptor
    text
    copied!<p>I'm trying to create an Interceptor able to change the language but I can not change it.</p> <p>Relevant Interceptor code:</p> <pre><code>public String intercept(ActionInvocation invocation) throws Exception { ActionMapping mapping = (ActionMapping) invocation .getInvocationContext() .get(ServletActionContext.ACTION_MAPPING); Map&lt;String, Object&gt; params = mapping.getParams(); if (params != null) { Locale locale = (Locale) params.remove(LOCALE_PARAMETER); if (locale != null) { ActionContext.getContext().setLocale(locale); } } return invocation.invoke(); } </code></pre> <p>struts.xml:</p> <pre><code>&lt;package name="default" extends="struts-default" namespace="/"&gt; &lt;result-types&gt; &lt;result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" /&gt; &lt;/result-types&gt; &lt;interceptors&gt; &lt;interceptor name="navigator" class="it.apps.mca.web.interceptors.NavigatorInterceptor"&gt; &lt;/interceptor&gt; &lt;interceptor name="locale" class="it.apps.mca.web.interceptors.internationalizations.LocaleInterceptor"&gt; &lt;/interceptor&gt; &lt;interceptor-stack name="customStack"&gt; &lt;interceptor-ref name="navigator" /&gt; &lt;interceptor-ref name="locale" /&gt; &lt;interceptor-ref name="defaultStack"/&gt; &lt;/interceptor-stack&gt; &lt;/interceptors&gt; &lt;action name="locale" class="it.apps.mca.web.actions.internationalizations.LocaleAction"&gt; &lt;interceptor-ref name="customStack"&gt;&lt;/interceptor-ref&gt; &lt;result name="success" type="redirect"&gt; &lt;param name="location"&gt;${target}&lt;/param&gt; &lt;param name="parse"&gt;true&lt;/param&gt; &lt;/result&gt; &lt;/action&gt; &lt;action name="login" class="it.apps.mca.web.actions.authentication.LoginAction"&gt; &lt;result name="success" type="tiles"&gt;/welcome.tiles&lt;/result&gt; &lt;result name="input"&gt;index.jsp&lt;/result&gt; &lt;result name="error"&gt;index.jsp&lt;/result&gt; &lt;/action&gt; &lt;/package&gt; </code></pre> <p>I know i18n interceptor already exists. I added an interceptor that performs redirections. After adding this interceptor, I lose the location of the page. The same thing happens if I perform a redirect through the action. You know tell me the reason?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload