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

 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>

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值