问题如下:
- index.jsp页面:
- <jsp:forward page="show.action"></jsp:forward>
-
- 在struts.xml配置如下:
- <package name="struts2" extends="struts-dafult">
- <action name="show" class="action.ShowAction">
- <result name="showinfo">/showinfo.jsp</result>
- </action>
- </package>
- 在运行时出现404错误(找不到 show.action )
问题原因:
struts2拦截器把forward这个请求拦截了。
解决方法:
修改web.xml文件
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>
- org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
- </filter-class>
- </filter>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- 修改为:
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>
- org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
- </filter-class>
- </filter>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>/*</url-pattern>
- <dispatcher>REQUEST</dispatcher>
- <dispatcher>FORWARD</dispatcher>
- </filter-mapping>