错误处理页面的制作404,和500
2008-07-14 10:06
71 查看
错误处理页面的制作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> 阅读更多
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> 阅读更多
相关文章推荐
- 错误处理页面的制作404,和500
- 错误处理页面的制作404,和500
- spring boot 下 500 404 错误页面处理
- web应用设置统一友好错误页面,处理404,500等错误
- spring boot 下 500 404 错误页面处理
- 为Nginx制作404 403 500等错误页面
- spring boot 下 500 404 错误页面处理
- spring boot下 500 404 错误页面处理的方法
- spring boot 下 500 404 错误页面处理
- spring boot 下 500 404 错误页面处理
- nginx 设置错误的自己定义404页面跳转到500
- 修改网站404,500的错误页面
- iis php web.config处理404,500等,跳转友好页面,显示500错误信息
- nginx 自定义404 500 错误页面
- springboot使用之四:错误页面404处理建议
- SpringMVC Controller设置400/404/500自定义错误页面
- 利用Nginx负载均衡的访问SpringBoot服务,还有如何利用Nginx实现404,500等错误页面的拦截
- Android webview处理404、500、断网、timeout页面的问题(by 星空武哥)
- django的403/404/500错误自定义页面的配置
- spring boot 自定义403 404 500 等错误页面