错误处理页面的制作404,和500

错误处理页面的制作404,和500
web.xml文件增加如下代码查看复制到剪切板打印
<error-page>
<error-code>404</error-code>
<location>/building.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>


building.jsp

<%@ page language="java" contentType="text/html; charset=GBK" isErrorPage="true" pageEncoding="GBK"%>
<%
response.setStatus(HttpServletResponse.SC_OK);
%>
对不起,您请求的页面没有找到!

<%@ page language="java" contentType="text/html; charset=GBK" isErrorPage="true" pageEncoding="GBK"%>
<%
response.setStatus(HttpServletResponse.SC_OK);
%>
对不起,您请求的页面没有找到!


error.jsp

<%@ page language="java" contentType="text/html; charset=GBK" isErrorPage="true" pageEncoding="GBK"%>
<%@ page import="java.io.*,java.util.*"%>
<%response.setStatus(HttpServletResponse.SC_OK);

%>
<body>
程序发生了错误,有可能该页面正在调试或者是设计上的缺陷.

你可以选择
<a href=<%=request.getContextPath()+"/forum/new.jsp" %>>反馈</a>
提醒我... 或者
<a href="javascript:history.go(-1)">返回上一页</a>
<hr width=80%>
<h2><font color=#DB1260>JSP Error Page</font></h2>

<p>An exception was thrown: <b> <%=exception.getClass()%>:<%=exception.getMessage()%></b></p>
<%
System.out.println("Header....");
Enumeration<String> e = request.getHeaderNames();
String key;
while(e.hasMoreElements()){
key = e.nextElement();
System.out.println(key+"="+request.getHeader(key));
}
System.out.println("Attribute....");
e = request.getAttributeNames();
while(e.hasMoreElements()){
key = e.nextElement();
System.out.println(key+"="+request.getAttribute(key));
}

System.out.println("arameter....");
e = request.getParameterNames();
while(e.hasMoreElements()){
key = e.nextElement();
System.out.println(key+"="+request.getParameter(key));
}
%>
111<%=request.getAttribute("javax.servlet.forward.request_uri") %>

<%=request.getAttribute("javax.servlet.forward.servlet_path") %>

<p>With the following stack trace:</p>
<pre>
<%exception.printStackTrace();
ByteArrayOutputStream ostr = new ByteArrayOutputStream();
exception.printStackTrace(new PrintStream(ostr));
out.print(ostr);
%>
</pre>
<hr width=80%>
</body>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值