Glassfish中未处理的异常详细信息

Ser*_*rin 1 unhandled jsp servlets exception glassfish

我想在Glassfish中抛出未处理的异常时看到异常细节(在网页中,而不是日志).

此错误页面显示但没有有用的信息.抛出异常时是否可以选择查看更多详细信息?(就像在asp.net中,如果你在web.config中使debugmode为true,你可以看到异常细节)

HTTP状态500 -

类型异常报告

信息

description服务器遇到内部错误(),导致无法完成此请求.

例外

java.lang.NullPointerException注意Oracle GlassFish Server 3.1日志中提供了异常的完整堆栈跟踪及其根本原因.

Oracle GlassFish Server 3.1

谢谢

hom*_*ome 5

通常,您应该仅在开发环境中执行此类操作,因为它将内部应用程序详细信息发布到外部世界(安全问题).不过,您可以在web.xml中定义一个通用异常jsp:

<web-app>
     <error-page>
         <exception-type>java.lang.Throwable</exception-type>
         <location>/WEB-INF/jsp/throwable.jsp</location>
    </error-page>
</web-app>
Run Code Online (Sandbox Code Playgroud)

throwable.jsp的页面元素必须包含一个isErrorPage属性:

<%@ page isErrorPage="true" %>
Run Code Online (Sandbox Code Playgroud)

此属性定义类型的变量异常java.lang.Throwable,因此您可以检查内部的异常throwable.jsp:

<div style="font-family: monospace">
    <pre>
<% exception.printStackTrace(new java.io.PrintWriter(pageContext.getOut())); %>
    </pre>
</div>
Run Code Online (Sandbox Code Playgroud)