Struts2 - 在浏览器中查看操作结果的真实目标网址
在 Struts2 中,当从成功的操作返回时,我希望用户浏览器向用户显示他正在导航到的真实 url,而不是原始的操作调用。据我了解,我无法使用 type="redirect" 操作,因为我需要从值堆栈中提取操作结果。
比方说,例如,如果我定义一个操作来在数据库中保存新元素,然后我想让用户查看整个元素列表...:
<action name="doSavePage" class="FbPageAdmin" method="doSavePage" >
<result name="input">/pageadmin.jsp</result>
<result name="error">/pageadmin.jsp</result>
<result name="success">/pageList.jsp</result>
</action>
如果操作成功完成,我希望用户参见mysite.com/pageList.jsp,并且不是mysite.com/doSavePage.action
这可能吗?
提前谢谢大家了!
In Struts2, when returning from a successful action, I want the user browser to show to the user the real url he is navigating into, and not the original call to action. As far as I understand, I cannot use a type="redirect" action because I need to pull the action results from the value stack.
Let's say, for example, if I define an action to save a new element in my db, and then I want to take the user to see the whole list of elements...:
<action name="doSavePage" class="FbPageAdmin" method="doSavePage" >
<result name="input">/pageadmin.jsp</result>
<result name="error">/pageadmin.jsp</result>
<result name="success">/pageList.jsp</result>
</action>
If the action finishes successfully, I want the user to see mysite.com/pageList.jsp, and not mysite.com/doSavePage.action
Is that possible?
Thanks everybody in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么要显示 JSP 文件名?
无论如何,我不确定我是否理解了;如果您想在添加对象后显示对象列表,请重定向到“列表”操作(和/或方法)。无论如何,您应该在 POST 之后执行重定向(重定向后获取模式),以避免在刷新时重新提交相同的表单数据。
另外,理想情况下,JSP 应该位于 /WEB-INF 下,以禁止客户端直接访问。
Why would you want to have the JSP file name shown?
In any case, I'm not sure I understand; if you want to show a listing of objects after adding one, redirect to the "list" action (and/or method). You should do a redirect after a POST anyway (the post-redirect-get pattern) to avoid resubmitting the same form data on a refresh.
Also, ideally, JSPs should live under /WEB-INF to disallow direct aclient access.