[英]Struts 2.3 Store Interceptor : How to pass ActionErrors from Interceptor to Action?
我一直在 Struts 2 文档中阅读有关StoreInterceptor
的内容,它讨论了如何将 StoreInterceptor 粘贴到您的struts-config.xml
中的 Action 定义中,并且它可以正常工作。 但那是如果您从 Action 中创建和添加ActionErrors
。
我的问题是我正在使用LoginInterceptor
进行登录,如果登录失败,则会添加一个ActionError
如下所示:
((ActionSupport) invocation.getAction()).addActionError("Login failed");
它添加得很好,但是当我到达在 LoginInterceptor之后调用的LoginInterceptor
, ValidationAwareSupport.actionErrors
为null
。
我认为通过像这样添加StoreInterceptor
,它会在请求或会话中存储ActionErrors
(使用operationMode
"store"
或"retreive"
参数):
<action name="login" class="...LoginFormAction" >
<interceptor-ref name="store">
<param name="operationMode">store</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="input" type="tiles">adminLogin</result>
<result name="success" type="tiles">adminLogin</result>
</action>
但它不起作用。 我还尝试将StoreInterceptor
直接添加到 defaultStack,这也不起作用。
StoreInterceptor
是否不仅用于保存 Actions 之间的ActionErrors
,还用于保存 Interceptor 和 Actions 之间的ActionErrors
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.