<%-- Document : throwEx Created on : 2020-4-11, 22:04:20 Author : Administrator --%> <%@page contentType="text/html" pageEncoding="UTF-8" errorPage="error.jsp"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title> JSP脚本的异常机制 </title> </head> <body> <% int a = 6; int c = a / 0; %> </body> </html>
<%-- Document : error Created on : 2020-4-11, 22:07:16 Author : Administrator --%> <%@page contentType="text/html" pageEncoding="UTF-8" isErrorPage="true"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title> 异常处理页面 </title> </head> <body> 异常类型是:<%=exception.getClass()%><br/> 异常信息是:<%=exception.getMessage()%><br/> </body> </html>