当前位置: 代码迷 >> JavaScript >> struts2处置404/500出错页面,找不到action或jsp
  详细解决方案

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

热度:81   发布时间:2012-08-31 12:55:03.0
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等是自己定义的出错显示页面

  相关解决方案