Struts2 RedirectAction:参数拦截器和工作流程?
我的 Struts2 应用程序的常见用例是,我有一些操作来收集 JSP 页面上显示的数据。我将这些称为“视图操作”。
但我也有逻辑动作,它在后台“做”一些事情(比如注册用户)。这些可能还有一个需要在 JSP 上显示的 bean,但我需要将结果重定向到视图操作之一。
遗憾的是,我从第一个操作中需要的 bean 没有传输到 ValueStack,而只是从视图操作中获取的值。示例:
<action name="mailConfirm" class="de.abelssoft.updateyeti.Frontend.MailConfirmer">
<result name="login" type="redirectAction">
<param name="actionName">register</param>
<param name="email">${person.email}</param>
</result>
<result name="input" type="redirectAction">
<param name="actionName">register</param>
</result>
</action>
我在这里缺少什么模式?或者我是否必须在响应上下文中存储我需要的所有内容?
My common usecase for my Struts2 application is that I have Actions that collect data which are presented on an JSP page. I'll call these view-actions.
But then I also have logic actions, which "do" something in the background (like registering a user). These might also have a bean that needs to be shown on an JSP, but I need to redirect the result to one of the view-actions.
Sadly, the bean I need from the first action doesn't get transferred to the ValueStack, but only values from getters from the view action. Example:
<action name="mailConfirm" class="de.abelssoft.updateyeti.Frontend.MailConfirmer">
<result name="login" type="redirectAction">
<param name="actionName">register</param>
<param name="email">${person.email}</param>
</result>
<result name="input" type="redirectAction">
<param name="actionName">register</param>
</result>
</action>
What is the pattern I'm missing here? Or do I have to store everything I need in the response context?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有回答这个问题,所以我会告诉你我做了什么。很抱歉没有提供“好的答案”。
我写了两个拦截器。一种用于将消息对象临时存储在用户会话中的逻辑操作,另一种用于将消息对象从用户会话中取出并删除的查看操作。
我在需要时使用了逻辑操作拦截器,并对所有其他操作使用了 viewaction 拦截器,以确保当在视图操作之前发生操作重定向时,将找到并使用消息对象。
I got no answer to this question, so I'll tell you what I've done. Sorry for not providing a "good answer".
I wrote two interceptors. One for the logical action that would store message-objects in the user session temporarily and one for my view actions that would take and remove them out of the usersession.
I used the logical action interceptor where needed and used the viewaction interceptor for all other action to make sure that when an action redirection has happened before the view action, the message-objects will be found and used.