JSP errorPage设置方法
程序员文章站
2024-02-15 21:34:28
1.设置errorpage:errorpage.jsp 复制代码 代码如下: <%@page iserrorpage="true"%> ...
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>
复制代码 代码如下:
<%@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>