Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java isErrorPage=“false”被容器忽略_Java_Jsp_Page Directives - Fatal编程技术网

Java isErrorPage=“false”被容器忽略

Java isErrorPage=“false”被容器忽略,java,jsp,page-directives,Java,Jsp,Page Directives,说到这里,我有.jsp页面和错误页面,如果第一个页面出现问题,那么错误页面应该出现,现在我不想让第一个页面重定向到错误页面,通过在错误页面上为isErrorPage属性赋值false,第一个页面应该显示愚蠢的异常跟踪,但是,第一个页面一直重定向到错误页面,下面是我的简单错误页面代码: <%@page contentType="text/html" pageEncoding="UTF-8" isErrorPage="false"%> <!DOCTYPE html> &

说到这里,我有.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>
这是我谈论的第一页:

 <%@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>

非常感谢。

您需要在web.xml中将其设置为错误页面。请参阅。

iErrorPage=false不会阻止您重定向错误页面。只要您在第一个JSP中指定了errorPage,它就会重定向到它的errorPage。在您的示例中,它重定向到另一个错误页面

isErrorPage属性决定隐式对象异常是否可用。在JSP到Servlet的转换过程中,将基于此属性定义服务内方法异常对象。如果设置为false,则无法在该页面中使用异常对象。如果设置为true,则异常对象将出现,并且可以使用它

在您的情况下,如果要显示异常,您必须执行以下任一操作, 1.在另一个错误页面中,定义isErrorPage=true并通过隐式对象异常显示或捕获异常。
2.删除第一个jsp页面中的errorPage属性。

嘿,我知道DD中的error page标记,但我只想知道我的代码有什么问题,谢谢你。@Real所以你的问题是错误页面一直出现?您已经从部署描述符中删除了它?因为我正在阅读JSR245,isErrorPage的唯一影响是一些隐式变量是否可用。