JSP_错误提示_友好页面

2021-07-15 20:06

阅读:589

标签:请求转发   w3c   技术分享   sage   转发   lang   错误提示   location   ror   

技术分享

示例1:(涉及到请求转发)

技术分享

1.jsp----------------errorPage="/error.jsp"请求转发不需要写web应用名称

 1 @ page language="java" import="java.util.*" pageEncoding="utf-8" session="false" errorPage="/error.jsp" %>
 2 DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 3 html>
 4   head>
 5   head>
 6   body>
 7       xxxx中文
 8       
 9           int i = 1/0;
10        %>
11   body>
12 html>

error.jsp

 1 @ page language="java" import="java.util.*" pageEncoding="utf-8" isErrorPage="true"%>
 2 DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 3 html>
 4   head>
 5   head>
 6   body>
 7       服务器出错了哦...亲~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 8       = exception.getMessage() %>
 9   body>
10 html>

 示例 2: web.xml(推荐)

 1 xml version="1.0" encoding="UTF-8"?>
 2 web-app version="2.5" 
 3     xmlns="http://java.sun.com/xml/ns/javaee" 
 4     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 5     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
 6     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 7 
 8     
 9         exception-type>java.lang.Throwableexception-type>
10         location>/error/500.jsplocation>
11     error-page>
12 
13     error-page>
14         error-code>404error-code>
15         location>/error/404.jsplocation>
16     error-page>
17     
18   welcome-file-list>
19     welcome-file>index.jspwelcome-file>
20   welcome-file-list>
21 web-app>

 

JSP_错误提示_友好页面

标签:请求转发   w3c   技术分享   sage   转发   lang   错误提示   location   ror   

原文地址:http://www.cnblogs.com/dreamHighMjc/p/7072452.html


评论


亲,登录后才可以留言!