当前位置:主页 > 软件编程 > JSP代码 >

JSP errorPage设置方法

时间:2021-07-16 10:42:26 | 栏目:JSP代码 | 点击:

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>

您可能感兴趣的文章:

相关文章