web.xml下配置
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/500.html</location>
</error-page>
<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>/WEB-INF/jsp/errors/error.jsp</location>
</error-page>
<html>
<head>
<title>404错误页面</title>
<meta charset="UTF-8">
</head>
<style>
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
color: #B0BEC5;
display: table;
font-weight: 100;
font-family: 'Lato';
}
.container {
text-align: center;
display: table-cell;
vertical-align: middle;
}
.content {
text-align: center;
display: inline-block;
}
.title {
font-size: 42px;
margin-bottom: 40px;
}
</style>
<body>
<div class="container">
<div class="content">
<div class="title">404 很抱歉,您查看的页面找不到了!</div>
</div>
</div>
</body>
</html>