可以在index.jsp页面中制定错误信息
<%--页面发生500错误就自动跳转到该自定义页面--%>
<%@ page errorPage="error/500error.jsp" %>
自定义页面跳转到错误信息的图片页:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>500</title>
</head>
<body>
<img src="img/500.jpg" alt="服务器错误!">
</body>
</html>
发生500错误时,跳转到图片页面:
同时可以在web.xml中配置错误信息,error-code为错误的状态码,localtion为错误相应的页面:
<!-- 配置错误信息-->
<error-page>
<error-code>500</error-code>
<location>/error/500error.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<!-- <exception-type></exception-type>-->
<location>/error/404error.jsp</location>
</error-page>