tomcat 配置异常/404页面
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                tomcat 配置异常/404页面
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                前言
- tomcat 9.0.45
配置異常/404頁面
在web.xml文件中添加類似配置:
<error-page><error-code>404</error-code><location>/404.jsp</location> </error-page>沒有web.xml?自建一個。
 不會建?tomcat自帶的應用里有web.xml,復制粘貼一下(拿來用)。
錯誤頁面可以是JSP,也可以是HTML。
來個示例
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaeehttp://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"version="4.0"metadata-complete="true"><display-name>Welcome to Tomcat</display-name><description>Welcome to Tomcat</description><!-- 404 頁面不存在錯誤。同理,可以添加其它的錯誤碼 --><error-page><error-code>404</error-code><location>/ErrorPage/404.html</location></error-page><!-- 400錯誤 --><error-page><error-code>400</error-code><location>/ErrorPage/error.html</location></error-page><!-- 500 服務器內部錯誤 --><error-page><error-code>500</error-code><location>/ErrorPage/error.html</location></error-page><!-- java.lang.Exception異常錯誤 --><error-page><exception-type>java.lang.Exception</exception-type><location>/ErrorPage/error.html</location></error-page><!-- java.lang.NullPointerException異常錯誤 --><error-page><exception-type>java.lang.NullPointerException </exception-type><location>/ErrorPage/error.html</location></error-page><!-- javax.servlet.ServletException異常錯誤。同理,可以添加其它的錯誤類型--><error-page><exception-type>javax.servlet.ServletException</exception-type><location>/ErrorPage/error.html</location></error-page></web-app>總結
以上是生活随笔為你收集整理的tomcat 配置异常/404页面的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 烫狗脊的功效与作用、禁忌和食用方法
- 下一篇: 净砂仁的功效与作用、禁忌和食用方法
