1.项目结构
2.通过<%@page errorPage="error/500.jsp" %>设置
<%@page contentType="text/html;charset=UTF-8" language="java" %>
<%@page errorPage="error/500.jsp" %>
<%-- 定制错误页面--%>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
int x=10/0;
%>
</body>
</html>
3.通过配置web.xml设置
<web-app>
<error-page>
<error-code>404</error-code>
<location>/error/404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error/500.jsp</location>
</error-page>
</web-app>