首页 > 编程 > JSP > 正文

JSP中errorPage设置方法

2019-11-17 04:09:47
字体:
来源:转载
供稿:网友

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>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表