IT码农库

您当前所在位置:首页 > 网络编程 > JSP编程

JSP编程

JSP errorPage设置方法

网络 2009-10-04JSP编程9170
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>
大图广告(830*140)