java web 配置異常攔截器

在web.xml中配置

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <error-page>
    <error-code>400</error-code>
    <location>/404.html</location>
  </error-page>
  <!-- 404 頁面不存在錯誤 -->
  <error-page>
    <error-code>404</error-code>
    <location>/404.html</location>
  </error-page>
  <!-- 500 服務器內部錯誤 -->
  <error-page>
    <error-code>500</error-code>
    <location>/404.html</location>
  </error-page>
  <!-- java.lang.Exception異常錯誤,依據這個標記可定義多個類似錯誤提示 -->
  <error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/404.html</location>
  </error-page>
  <!-- java.lang.NullPointerException異常錯誤,依據這個標記可定義多個類似錯誤提示 -->
  <error-page>
    <exception-type>java.lang.NullPointerException</exception-type>
    <location>/404.html</location>
  </error-page>
  <error-page>
    <exception-type>javax.servlet.ServletException</exception-type>
    <location>/404.html</location>
  </error-page>
</web-app>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章