我想像这样使用 RequestDispacher
将请求从 Servlet 转发到 Action
RequestDispatcher dispatcher=request.getRequestDispatcher("hello.action");
dispatcher.include(request, response);
它不起作用。我该如何解决这个问题?
最佳答案
为了做到这一点,您可能还需要将过滤器设置为在 FORWARD 上运行(和 INCLUDE,如您的代码所示,尽管您声明您想要 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>
关于java - 如何将请求从servlet 转发到struts2 的action?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16119925/