JSP errorPage设置方法

1.设置errorPage:errorPage.jsp
复制代码 代码如下:
<%@page isErrorPage="true"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
Error~!
<%=exception.getMessage()%>
</body>
</html>

2.应用
复制代码 代码如下:
<%@page info="Bad page"%>
<%@page errorPage="errorPage.jsp" %> //出错后转到
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
boolean tf = true;
if(tf){
String info = getServletInfo();
throw new Exception("Exception in:" + info);
}
%>
</body>
</html>

jsp技术JSP errorPage设置方法,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。