1 <? Xml version = "1.0" encoding = "UTF-8"?> 2 <web-app version = "2.4" 3 xmlns = "http://java.sun.com/xml/ns/j2ee" 4 xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" 5 xsi: schemaLocation = "http://java.sun.com/xml/ns/j2ee 6 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 7 8 <error-page> 9 <error-code> 404 </error-code> 10 <location>/notfound. jsp </location> 11 </error-page> 1213 <error-page> 14 <error-code> 500 </error-code> 15 <location>/error. jsp </location> 16 </error-page> 17 18 </web-app>
In a java web project. after the preceding two <error-pages> are configured in xml, the page will jump to notfound under WebRoot as long as the page has a 404 error. the jsp page will jump to error if a 500 error occurs. jsp page instead of redirecting to a 404 html error page.
For more information about the threat of redirecting to an html error page of 404 or 500 to a website, see my other blog post: How to declare and use the error handling page of JSP.