JSP中errorPage设置方法

来源:网络时间:2026-10-23 20:08:42

  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>

本文内容为用户投稿,该文观点仅代表作者本人,不代表本站立场,本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请将相关资料发送至[email protected]进行反馈与投诉,一经查实,立即处理!