如何轻松地从一个jsp转发到多个action
我是 struts 的新手,这是我的问题:
我有一个可以通过多个操作访问的 jsp。在此 jsp 上,我有一个“后退”按钮,该按钮必须将用户转到上一页。上一页必须用原来的参数调用。 实现这一目标的解决方案是什么?
我尝试向 jsp 传递一个参数,以告诉用户单击“后退”按钮时调用哪个操作(即我以这种方式调用我的页面:/myJsp?back=loadMyPage.do):并在 jsp 中“后退”按钮使用此“后退”参数将用户重定向到适当的操作。
我认为当只有一个(或几个)页面使用这种机制时,这可能是一个很好的解决方案,但是当多个页面分别被多个操作使用时,它会变得复杂:我们必须将“back”参数传递给每个页面。
所以我想知道如何轻松实现这一点。我还问自己在 jsp 中完成转发工作是否有意义:在操作类中完成所有工作是否更好?
我希望我说清楚了
I am quite a newbie on struts, and here is my problem :
I have a jsp which is accessed from several actions. On this jsp, i have a 'Back' button which has to forward the user to the previous page. The previous page must be called with the originally parameters.
What are the solutions to achieve this ?
I tried to pass a parameter to the jsp to tell which action to call when the user clicks the 'back' button (ie i call my page in such a way : /myJsp?back=loadMyPage.do) : and in the jsp the 'back' button uses this 'back' parameter to redirect the user to the adequate action.
I think it can be a good solution when only one (or a few) pages are using this mechanism, but it gets complicated when several pages are each used by several actions : we d have to pass the 'back' parameter to each page.
So i m wondering how to achieve this easily. I m also asking myself if it has sense to do that forwarding work inside a jsp : is it better to do all work in actions classes ?
I hope i was clear
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是否有某种原因导致使用浏览器的后退按钮效果不佳?如果你确实需要自己的按钮,难道不可以直接调用
history.back()
吗?Is there some reason that using the browser's back button doesn't work well enough? If you really need your own button, can it not just call
history.back()
?