Simple configuration of the Java Web Engineering error page

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.