Xml代碼
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文件
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>
作者:張慧