在我的JSP页面中,我首先指定了一个errorPage,以便向用户显示标准消息(尽管我没有向用户显示JSP错误)。
<%@ page errorPage="myErrorPage.jsp" trimDirectiveWhitespaces="true" %>
但是,当我包含此页面指令时,它会导致JasperExceptions不再写入我的应用程序日志。我需要在app日志中看到JasperException,这样我才能在JSP中找到错误。
有没有办法指定一个errorPage并仍然告诉Jasper继续在日志中记录JasperExceptions?
答案 0 :(得分:0)
我确实找到了办法。指定的错误处理页面需要重新抛出与JSP相关的异常。 例如:myErrorPage.jsp将是:
<%@page isErrorPage="true" %>
<html>
<head>
<%--
*************************************************************************
To be used for displaying jsp error .
On every jsp page insert the directive below:
<%@page errorPage="errorsnaps.jsp" buffer="64kb" %>
Note: page buffer attribute shown above is also a good idea.
Otherwise, if default 8k buffer overflows,
the original page will start to be output BEFORE a jsp error is encountered,
which causes this page to come out after a partial erroneous page, creating a big mess!
TODO: Could just have an errorPage designation in web.xml -- that makes sure to get all pages.
*************************************************************************
--%>
</head>
<body>
<div>
A generic user-friendly message that does not disclose the actual error.
</div>
</body>
</html>
<%
if ( exception != null )
{
out.flush();
throw (exception);
}
%>