1. 确保页面有一定量的内容,小于512字节会显示成IE浏览器的404页面(Eclipse就是),不过也可以在chrome浏览器等打开。
2. error.jsp设置isErrorPage="true",比如:
<%@page pageEncoding="UTF-8" isErrorPage="true"%>
<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
<meta content='text/html;charset=UTF-8' http-equiv='content-type'>
<title>错误页面</title>
</head>
<body>
错误页面blabla
......
</body>
</html>
3. web.xml最后写上配置,比如:
<web-app>
...
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/error.jsp</location>
</error-page>
</web-app>
4. 错误页面放web-inf下,不给用户访问,更好