萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> jsp編程 >> jsp中error page設置方法

jsp中error page設置方法

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>

copyright © 萬盛學電腦網 all rights reserved