如何将请求从servlet转发到struts2的动作? [英] How to forward request from servlet to action of struts2?
本文介绍了如何将请求从servlet转发到struts2的动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想像这样使用 RequestDispacher
将请求从 Servlet 转发到 Action
I want to forward a request from Servlet to Action like this using RequestDispacher
like this
RequestDispatcher dispatcher=request.getRequestDispatcher("hello.action");
dispatcher.include(request, response);
它不起作用.我该如何解决这个问题?
It's not working. How can I resolve this problem?
推荐答案
为了做到这一点,您可能还需要将过滤器设置为在 FORWARD 上运行(和代码所示的 INCLUDE,尽管您声明想要 FORWARD):
In order to do this you may also need to set the filter to run on FORWARD (and INCLUDE as your code shows, although you state you want a FORWARD):
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher> <!-- If you want includes as well -->
</filter-mapping>
这篇关于如何将请求从servlet转发到struts2的动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文