从过滤器类调用struts 2动作

发布于 2024-11-30 07:37:54 字数 214 浏览 0 评论 0原文

我在我的 struts 2 应用程序中添加了一个过滤器。我正在使用这个过滤器来检查 cookie 值。如果找到适当的 cookie,那么我想将用户重定向到主页而不是正常的登录页面。 因此,为了显示主页,我想调用与主页关联的 struts 2 操作。 我尝试从过滤器调用 homepage.execute() 方法,但这不会显示与主页关联的结果(jsp 页面)。 请建议我一些从 Fiter 类调用主页操作的方法。

I added a filter in my struts 2 application. I am using this filter to check cookie values. If appropriate cookie is found then i want to redirect user to home page rather than normal login page.
So for displaying home page I want to call struts 2 action associated with home page.
I tried calling homepage.execute() method from filter, but this does not display the result(jsp page) associated with home page.
Please suggest me some way to call homepage action from fiter class.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

转瞬即逝 2024-12-07 07:37:54

我不知道你的要求是什么,但通常使用 Struts 2 拦截器是一个更好的主意。
无论如何,您不能直接从 Java 调用操作,因为它不会触发框架内容。相反,您应该考虑重定向到操作的映射网址(例如:response.sendRedirect("http://your_host_name/your_action_name.action"))

I don't know what your requirements are, but usually using a Struts 2 interceptor is a better idea.
Anyway you can't invoke action directly from Java because it would not trigger the framework stuff. Instead you should consider to redirect to the mapped url of the action (for example: response.sendRedirect("http://your_host_name/your_action_name.action") )

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文