JSP page, itself the server will also translate the page into a servlet page, so the request for the page is likely to be wrong, there will be a page similar to the following
This is not friendly to the customer.
1. JSP page <%@ The ErrorPage attribute in the page%> directive
You can configure the ErrorPage property in the <%@ page%> directive in the JSP page, and when an error occurs accessing this page, it jumps to the configured friendly page
<%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8" errorpage="errorpage.jsp" %>
Jump to the error page ... It looks a lot better then.
2. Configure Web. xml
In the Java Web project, you can also configure a global error page configuration for the. XML configuration file, so that errors occur in the project and will jump to the appropriate page.
<!--Global error Handling page configuration - <Error-page> <!--when a server error occurs - <Error-code>500</Error-code> < Location>/errorpage.jsp</ Location> </Error-page> <Error-page> <!--resources not found - <Error-code>404</Error-code> < Location>/404.html</ Location> </Error-page>
When configured, the page is not found, or the resource access does not exist
Note:
When the ErrorPage attribute is configured in the JSP, the page error ignores the <error-code>500</error-code> configuration (nearest principle) in Web. Xml. You can configure the special processing page on which a page error occurs based on this
Simple configuration of the Java Web Engineering error page