web.xml配置404,500出错页面

xml 页面
Xml代码
1. <!-- 400错误 -->
2.<error-page>
3.<error-code>400</error-code>
4.<location>/error.jsp</location>
5.</error-page>
6.<!-- 404 页面不存在错误 -->
7.<error-page>
8.<error-code>404</error-code>
9.<location>/error.jsp</location>
10.</error-page>
11.<!-- 500 服务器内部错误 -->
12.<error-page>
13.<error-code>500</error-code>
14.<location>/error.jsp</location>
15.</error-page>
16.<!-- java.lang.Exception -->
17.<error-page>
18.<exception-type>java.lang.Exception</exception-type>
19.<location>/error.jsp</location>
20.</error-page>
21.<!-- java.lang.NullPointerException -->
22.<error-page>
23.<exception-type>java.lang.NullPointerException </exception-type>
24.<location>/error.jsp</location>
25.</error-page>
26.<error-page>
27.<exception-type>javax.servlet.ServletException</exception-type>
28.<location>/error.jsp</location>
29.</error-page>
<!-- 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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值