简体   繁体   English

isErrorPage =“ false”被容器忽略

[英]isErrorPage=“false” is ignored by container

Getting to the point, I have .jsp page and error page, well if there is something goes wrong with the first one, the error page should turn up then, now i don't want the first page to redirect to the error page anymore, by assigning false to isErrorPage attribute at the error page, the first page should display that stupid exception trace, however the first page keeps redirecting to the error page, here is my simple Error page code : 到目前为止,我有.jsp页面和错误页面,如果第一个页面出了问题,那么错误页面应该会出现,现在,我不希望第一个页面重定向到错误页面了,通过在错误页面上为isErrorPage属性分配false,第一页应该显示该愚蠢的异常跟踪,但是第一页不断重定向到错误页面,这是我简单的错误页面代码:

 <%@page contentType="text/html" pageEncoding="UTF-8" isErrorPage="false"%>
 <!DOCTYPE html>
 <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
      <body>
       <h1>guess what ? this is supposed to be an error page</h1>
     </body>
</html>

here's the first page I've been talking about : 这是我一直在谈论的第一页:

 <%@page contentType="text/html" pageEncoding="UTF-8" errorPage="anotherErrorPage.jsp" %>
   <!DOCTYPE html>
 <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <title>JSP Page</title>
    </head>
  <body>
      <h1>Hello World!</h1>

      <% int i = 3/0;%>
  </body>
</html>

thanks a zillion . 谢谢你。

isErrorPage="false" does not stop you to redirect error page. isErrorPage =“ false”不会阻止您重定向错误页面。 As long as you specified errorPage in the first JSP, it will redirect to its errorpage. 只要您在第一个JSP中指定了errorPage,它就会重定向到其errorpage。 In you example it redirects to "anotherErrorPage". 在您的示例中,它重定向到“ anotherErrorPage”。

isErrorPage attribute decides whether the implicit object exception will be available or not. isErrorPage属性决定隐式对象异常是否可用。 During JSP to Servlet conversion, In service() method, based on this attribute exception object would be defined. 在从JSP到Servlet的转换期间,将基于此属性异常对象在service()方法中定义。 If you set false you can't use exception object in that page.If you set true exception object will be there and you can use it 如果设置为false,则不能在该页面中使用异常对象。如果设置为true,则可以使用异常对象。

In your case If you want to show the exception you have todo either of the below, 如果您要显示异常,则必须执行以下任一操作,
1. In anotherErrorPage, define isErrorPage="true" and display or catch the exception by implicit object "exception". 1.在anotherErrorPage中,定义isErrorPage =“ true”并通过隐式对象“ exception”显示或捕获异常。
2.Remove errorPage attribute in first jsp page. 2.在第一个jsp页面中删除errorPage属性。

您需要在web.xml中将其设置为错误页面(请参见<error-page> )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM