您现在的位置: 万盛学电脑网 >> 程序编程 >> 网络编程 >> jsp编程 >> 正文

jsp中error page设置方法

作者:佚名    责任编辑:admin    更新时间:2022-06-22

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>