欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

JSP errorPage设置方法

程序员文章站 2023-11-26 19:46:52
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>