我正在使用 struts2 tile 插件 (v2.2.3),但在使用 I18nInterceptor 和 ExecuteAndWaitInterceptor 时遇到问题。本质上,当我出于某种原因添加 execAndWait 拦截器(参见下面的 xml)时,本地化不再起作用,当我尝试获取本地化文本(例如 TextProviderSupport.hasKey)时,我得到一个 NullPointerException(参见错误),我将其缩小到此代码本地化文本工具...
public static String findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args) {
ValueStack valueStack = ActionContext.getContext().getValueStack();
return findText(aClass, aTextName, locale, defaultMessage, args, valueStack);
}
...我假设 getValueStack() 出于某种原因为空,但我不知道为什么。有任何想法吗?
谢谢,瑞安
<pre><code>
java.lang.NullPointerException
at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:359)
at com.opensymphony.xwork2.TextProviderSupport.hasKey(TextProviderSupport.java:98)
at com.opensymphony.xwork2.ActionSupport.hasKey(ActionSupport.java:96)
at com.test.plus.PlusSupport.getCurrentLocale(PlusSupport.java:213)
at com.test.plus.import.Test.action.TestAction.testMethod(TestAction.java:801)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
at org.apache.struts2.interceptor.BackgroundProcess$1.run(BackgroundProcess.java:57)
at java.lang.Thread.run(Unknown Source)
</code></pre>
Struts.xml
<action name="Test/m/testMethod" method="testMethod" class="com.test.plus.import.Test.action.TestAction">
<result type="tiles">/WEB-INF/jsp/import/Test/testMethod.jsp</result>
<result name="success" type="tiles">/WEB-INF/jsp/import/Test/testMethod.jsp</result>
<result name="input" type="tiles">/WEB-INF/jsp/import/Test/testMethod.jsp</result>
<result name="error" type="tiles">/WEB-INF/jsp/import/Test/testMethod.jsp</result>
<result name="wait" type="tiles">/WEB-INF/jsp/import/execAndWait.jsp</result>
<interceptor-ref name="plusStack"/>
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="execAndWait">
<param name="excludeMethods">input,back,cancel</param>
</interceptor-ref>
</action>