如何在JSP中打印堆栈跟踪

如何在JSP中打印堆栈跟踪

本文介绍了错误页面 - 如何在JSP中打印堆栈跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我使用Spring SimpleMappingExceptionResolver在我的Spring应用程序中创建了异常处理。一切都很好现在我需要以某种方式在jsp页面中打印捕获到的异常。像邮件和堆栈跟踪。在我的jsp中,我在exception属性中找到了异常对象。我需要做的就是这样:

I've created exception handling in my Spring application using spring SimpleMappingExceptionResolver. Everything works fine. Now I need to somehow print the caught exception within the jsp page. Something like message and stack trace. In my jsp I've found the exception object in "exception" attribute. All I need to do is something like that:

${exception.printStackTrace()}

但我不知道如何。有没有办法这样做?: - )

But I don't know how. Is there any way how to do that?:-)

感谢任何建议,

Mateo


Mateo

推荐答案

我可以想到的最简单的解决方案是循环堆栈跟踪元素,利用 Throwable .getStackTrace()方法:

The easiest solution I can think of is to loop over the stack trace elements, taking advantage of the Throwable.getStackTrace() method:

<c:forEach items="${exception.stackTrace}" var="element">
    <c:out value="${element}" />
</c:forEach>

当然,您需要添加一些格式。

You'd need to add some formatting, of course.

这篇关于错误页面 - 如何在JSP中打印堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:51