自定义网页错误页面(400、404、500)

1、设计好比较有创意个性友好的错误页面


2、修改系统配置文件web.xml

  <!-- 400错误 -->
  <error-page>
   <error-code>400</error-code>
   <location>/error404.html</location>
  </error-page>
  <!-- 404 页面不存在错误 -->
  <error-page>
   <error-code>404</error-code>
   <location>/error404.html</location>
  </error-page>
  <!-- 500 服务器内部错误 -->
  <error-page>
   <error-code>500</error-code>
   <location>/error404.html</location>
  </error-page>
  <!-- java.lang.Exception异常错误,依据这个标记可定义多个类似错误提示 -->
  <error-page>
   <exception-type>java.lang.Exception</exception-type>
   <location>/error404.html</location>
  </error-page>
  <!-- java.lang.NullPointerException异常错误,依据这个标记可定义多个类似错误提示 -->
  <error-page>
   <exception-type>java.lang.NullPointerException</exception-type>
   <location>/error404.html</location>
  </error-page>
  <error-page>
   <exception-type>javax.servlet.ServletException</exception-type>
   <location>/error404.html</location>
  </error-page>

你可能感兴趣的:(400、404、500)