Home > Java > Java Basics > body text

Java custom error page implementation method

Release: 2019-11-28 09:35:26
Original
2484 people have browsed it

Java custom error page implementation method

java background custom error page: (Recommended: java video tutorial)

404 often appears in java background projects Or 500 and other errors,

If no settings are made, the server will return a 404 or 500 error page by default

to display the error page to the front end.

After mastering the error page settings, you can customize the 404 or 500 error page according to business needs.

Implementation principle:

When the service throws a 404 or 500 exception, the

servlet service will check whether error is set in the web or xml -page and error-code

If the set page can be found, the set page will be returned to the front end. If the set page cannot be found, the system default page will be returned to the front end.

Implementation code:

404.html:




    
    Title

404
Copy after login

500.html:




    
    Title

500
Copy after login

web.xml:


		404
		/404.html
	
	
		500
		/500.html
	
Copy after login

Implementation effect :

Java custom error page implementation methodFor more java knowledge, please pay attention to the java basic tutorial column.

The above is the detailed content of Java custom error page implementation method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!