日期:2014-05-16  浏览次数:20339 次

struts2处理404/500出错页面,找不到action或jsp
处理找不到action:

在struts.xml中添加:

<default-action-ref name="pageNotFund"></default-action-ref>

<action name="pageNotFund">
   <result>/pages/error.html</result>
</action>

pageNotFund 是自己定义的一个acion

处理找不到jsp:

在web.xml中添加:

<error-page>
  <error-code>401</error-code>
  <location>/error/404.htm</location>
</error-page>
<error-page>
  <error-code>402</error-code>
  <location>/error/404.htm</location>
</error-page>
<error-page>
  <error-code>403</error-code>
  <location>/error/404.htm</location>
</error-page>
<error-page>
  <error-code>404</error-code>
  <location>/error/404.htm</location>
</error-page>
<error-page>
  <error-code>500</error-code>
  <location>/error/500.htm</location>
</error-page>
<error-page>
  <exception-type>java.lang.NullPointerException</exception-type>
  <location>/error/npe.htm</location>
</error-page>

404.htm等是自己定义的出错显示页面