默认情况下servlet或者jsp页面转发到struts2会出现找不到路径的错误,需要在web.xml文件中配置struts映射的地方添加FORWARD声明,如下:
<filter-mapping>
<filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>查找filter-mapping的配置会发现,dispatcher的配置选项如:
< dispatcher>REQUEST|INCLUDE|FORWARD|ERROR< /disaptcher>
设定Filter对应的请求方式,有RQUEST,INCLUDE,FORWAR,ERROR四种,默认为REQUEST,所以这里要打开FORWARD。