Struts2 Handle 404 error page and wrong action

1. To handle 404 not found yourself, just add this code to your web.xml

  <error-page>
      <error-code>404</error-code>
      <location>/pageNotFound.jsp</location>
  </error-page>

2. To handle wrong action not mapped in Struts2, just add this code to struts.xml

 <package name="serveAll" namespace="" extends="struts-default">
    <action name="*">
	 <result>/pageNotFound.jsp</result>
      </action>
 </package>

 

posted @ 2015-04-14 17:46  小张的练习室  阅读(204)  评论(0编辑  收藏  举报