web application exception handling, error handling settings page

When javaweb project when reported 404, 500, etc. error, error page will jump, but in general this page we will define ourselves, to facilitate prompt the user, rather than the system allows customers to think out of the question.

A, Jsp page editing error message content

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="java.util.Date" isErrorPage="true" %>
<!DOCTYPE HTML>
<html>
  <head>
      <title>404错误友好提示页面</title>
      <!-- 3秒钟后自动跳转回首页 -->
      <meta http-equiv="refresh" content="3;url=${pageContext.request.contextPath}/index.jsp">
  </head>  
  <body>
      <body>
         <p>对不起,你要访问的页面没有找到,请联系管理员处理!" </p>
         <br/>
         3秒钟后自动跳转回首页,如果没有跳转,请点击
         <a href="${pageContext.request.contextPath}/index.jsp">这里</a>          
      </body>
  </body>
</html>

Two, web.xml configuration jump path
default WebRoot with myeclipe Project -> web.xml under the WEB-INF directory Add Configuration

<error-page>
    <error-code>404</error-code>        
    <location>/404Error.jsp</location>   ///404Error.jsp 根据自己项目文件位置
</error-page>

Project view:

Here Insert Picture Description
(404Error.jsp) to modify the position of the attribute values ​​loction web.xml file according jump jsp

effect:
Here Insert Picture Description

Published 16 original articles · won praise 3 · Views 537

Guess you like

Origin blog.csdn.net/outdata/article/details/102389354