【编者按】网学网JSP频道为大家收集整理了“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>