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>

 

你可能感兴趣的:(Struts2 Handle 404 error page and wrong action)