xml 页面
<!-- 400错误 --> <error-page> <error-code>400</error-code> <location>/error.jsp</location> </error-page> <!-- 404 页面不存在错误 --> <error-page> <error-code>404</error-code> <location>/error.jsp</location> </error-page> <!-- 500 服务器内部错误 --> <error-page> <error-code>500</error-code> <location>/error.jsp</location> </error-page> <!-- java.lang.Exception --> <error-page> <exception-type>java.lang.Exception</exception-type> <location>/error.jsp</location> </error-page> <!-- java.lang.NullPointerException --> <error-page> <exception-type>java.lang.NullPointerException </exception-type> <location>/error.jsp</location> </error-page> <error-page> <exception-type>javax.servlet.ServletException</exception-type> <location>/error.jsp</location> </error-page>
jsp页面
关键在于
1 isErrorPage="true"
2 response.setStatus(HttpServletResponse.SC_OK);
错误页面
<%@ page language="java" contentType="text/html; charset=GBK" isErrorPage="true" pageEncoding="GBK"%>
<%@ page import="java.io.*,java.util.*"%>
<%response.setStatus(HttpServletResponse.SC_OK);%>
<%
/**
* 本页面是在客户[ke hu]查找[cha zhao]的页面无法找到的情况[qing kuang]下调用[tiao yong]的
*/
response.setStatus(HttpServletResponse.SC_OK);
%>
<body>
程序发生了错误[cuo wu],有可能该页面正在调试[tiao shi]或者是设计上的缺陷[que xian].<br/>
你可以选择[xuan ze]<br/> <a href=<%=request.getContextPath()+"/forum/new.jsp" %>>反馈</a>
提醒我... 或者<br/><a href="javascript:history.go(-1)">返回上一页</a>
</body>