tomcat 屏蔽404和500錯誤

apache的配置
在conf文件夾中將#ErrorDocument 404 /missing.html   定義成自己的錯誤頁面
1.使用<error-page>元素來避免讓用戶看到HTTP404或HTTP500錯誤。
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒<error-page>
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒      <error-code>404</error-code>
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒      <location>/error_404.jsp</location>
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒</error-page>
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒<error-page>
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒      <error-code>500</error-code>
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒      <location>/error_500.jsp</location>
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒</error-page>2.配置<error-page>讓Web容器捕獲如下異常:
    <1>RuntimeException或Error
    <2>ServletException或它的子類
    <3>IOException或它的子類
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒<error-page>
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒      <exception-type>javax.servlet.ServletException</exception-type>
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒      <location>/error.jsp</location>
tomcat 屏蔽404和500錯誤 - 傑林 - 警醒  </error-page>
 
error_404.jsp 、 error_500.jsp、error.jsp可以根據需要自己設計
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章