重定向时存储Interceptor和松散值堆栈

时间:2012-10-07 23:58:35

标签: java-ee struts2

我有2个动作。首先显示表单,另一个显示表单。如果未将processAdd操作验证为redirectAction,则返回Add操作。 Store拦截器在“添加”操作上显示正确的错误,但在重定向操作期间,表单上填写的值将丢失。

loose Value Stack重定向,我明白了。

有什么解决方法吗?

不想使用结果参数,过多的工作。

 <action name="add" class="com.myapp.actions.StudentAction" method="input">
            <interceptor-ref name="store">
                <param name="operationMode">RETRIEVE</param>
            </interceptor-ref>
            <result name="input" type="tiles">/student.edit.tiles</result>
        </action>

        <action name="processAdd" class="com.myapp.actions.StudentAction">
            <interceptor-ref name="store">
                <param name="operationMode">STORE</param>
            </interceptor-ref>
            <interceptor-ref name="defaultStack" />
            <result name="success" type="redirectAction">list</result>
            <result name="input" type="redirectAction">add</result>
            <result name="failure" type="redirectAction">add</result>
        </action>

2 个答案:

答案 0 :(得分:1)

MessageStoreInterceptor

  

用于存储ValidationAware操作的消息/错误的拦截器   和字段错误到HTTP会话,这样它将是可检索的   在稍后阶段。这允许动作的消息/错误和字段   只有特定的HTTP请求才能提供更长的错误。

您无法使用关注操作消息/错误和字段错误的消息存储拦截器来获取值堆栈数据。

或者你可以使用链拦截器或在会话中存储值,甚至消息存储拦截器使用会话对象来存储消息/错误。

答案 1 :(得分:1)

您正在寻找的是Scope Interceptor,而不是商店拦截器。

相关问题