JSP_錯誤提示_友好頁面

來源:互聯網
上載者:User

標籤:請求轉寄   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     <error-page> 9         <exception-type>java.lang.Throwable</exception-type>10         <location>/error/500.jsp</location>11     </error-page>12 13     <error-page>14         <error-code>404</error-code>15         <location>/error/404.jsp</location>16     </error-page>17     18   <welcome-file-list>19     <welcome-file>index.jsp</welcome-file>20   </welcome-file-list>21 </web-app>

 

JSP_錯誤提示_友好頁面

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.