handlePageException(Exception e)
引數說明:<%@page language="java" pageEncoding="GBK" errorPage="error.jsp"%> <% Integer.parseInt("測試"); %>然後在 error.jsp 頁面丟擲異常訊息,關鍵程式碼如下:
<%@page language="java" pageEncoding="GBK" isErrorPage="true" errorPage="error2.jsp"%> <% pageContext.handlePageException(exception); %>最後在 error2.jsp 頁面輸出異常訊息,關鍵程式碼如下:
<%@page language="java" pageEncoding="GBK" isErrorPage="true"%> <% out.print(exception.getMessage()); %>
handlePageException(Throwable t)
引數說明:<%@page language="java" pageEncoding="GBK" errorPage="error.jsp"%> <% Integer.parseInt("測試"); %>然後在 error.jsp 頁面丟擲異常訊息,關鍵程式碼如下:
<%@page language="java" pageEncoding="GBK" isErrorPage="true" errorPage="error2.jsp"%> <% Throwable t = exception.getCause(); pageContext.handlePageException(t); %>最後在 error2.jsp 頁面輸出異常訊息,關鍵程式碼如下:
<%@page language="java" pageEncoding="GBK" isErrorPage="true"%> <% out.print(exception.getMessage()); %>