Spring 在自定义tomcat错误页面中获取一些堆栈跟踪信息
使用tomcat、spring、jsf将一些堆栈跟踪信息(可能是Exeception.message)放到我的自定义错误500页面上的最佳方式是什么?我只想显示执行的根本原因。以下是我在Struts中使用的JSP语法。在使用JSf时,您可能会得到这样或类似的结果Spring 在自定义tomcat错误页面中获取一些堆栈跟踪信息,spring,jsf,tomcat,Spring,Jsf,Tomcat,使用tomcat、spring、jsf将一些堆栈跟踪信息(可能是Exeception.message)放到我的自定义错误500页面上的最佳方式是什么?我只想显示执行的根本原因。以下是我在Struts中使用的JSP语法。在使用JSf时,您可能会得到这样或类似的结果 <!-- Get the exception object --> <c:set var="exception" value="${requestScope['javax.servlet.error.exception
<!-- Get the exception object -->
<c:set var="exception" value="${requestScope['javax.servlet.error.exception']}"/>
<!-- Exception message(s) -->
<p>${exception.message}</p>
<p><c:if test="${not empty exception.cause.message}">${exception.cause.message}</c:if></p>
<!-- Stack trace -->
<jsp:scriptlet>
exception.printStackTrace(new java.io.PrintWriter(out));
</jsp:scriptlet>
${exception.message}
${exception.cause.message}
printStackTrace(新java.io.PrintWriter(out));
我的解决方案是-
使用以下命令将错误jsp页面声明为错误页面-
<%@ page isErrorPage="true"%>
稍后在同一个jsp页面中,您可以访问“exception”对象,将堆栈跟踪打印到您想要的任何位置
<%exception.printStackTrace();%>
您希望如何处理堆栈跟踪?要在服务器日志中记录stacktrace,还是向用户显示堆栈跟踪(在XHTML/JSP页面中)?除非我添加了isErrorPage指令,否则该页面将被常规错误页面替换+1.