Struts2 Handle 404 error page and wrong action

时间:2022-06-01 19:09:58

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>