Java 为NullPointerException打印stacktrace时出现异常

Java 为NullPointerException打印stacktrace时出现异常,java,exception,nullpointerexception,scriptlet,Java,Exception,Nullpointerexception,Scriptlet,我的错误页面如下所示: <div class="hideShow" style="width:99%; text-align: center; display: none;" > <UL><LI> <strong><%=exception%> </strong></LI></UL> </div> 但我在控制台中遇到了这个错误: The method print

我的错误页面如下所示:

<div class="hideShow" style="width:99%; text-align: center;  display: none;" >
            <UL><LI> <strong><%=exception%> </strong></LI></UL>
</div> 
但我在控制台中遇到了这个错误:

The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
关于如何在控制台中显示空指针的stacktrace的任何建议。
但是,它对其他类型的异常很有效。

异常。printStackTrace(writer)
不返回值,因此无法将其打印到
输出中

更改代码

<div class="hideShow" style="width:99%; text-align: center;  display: none;" >
            <UL><LI> <strong><%exception.printStackTrace(response.getWriter());%> </strong></LI></UL>
</div> 


尝试了上述操作并立即获得此异常“Throwable类型中的printStackTrace(PrintStream)方法不适用于参数(JspWriter)”您是否同意PrintWriter?我也传递了PrintWrite对象,但出现此错误“JspWriter类型中的print(布尔)方法不适用于参数(void)”我不明白你的意思,不要用方法打印。请使用我的答案。抱歉,页面未刷新。我现在得到跟踪。多谢!
The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
<div class="hideShow" style="width:99%; text-align: center;  display: none;" >
            <UL><LI> <strong><%exception.printStackTrace(response.getWriter());%> </strong></LI></UL>
</div>