我在业务层抛出了一个自定义的RuntimeException,然后在web.xml配置了error-page ,跳转到ExceptionHandel 这个servlet进行统一处理:
<error-page>
<exception-type>exception.CommonException</exception-type>
<location>/servlet/ExceptionHandel</location>
</error-page>
现在的问题是我该如何获取到这个异常的信息 我试了一下这样获取异常信息:
String status_code = "异常类型的整形值: "+ request.getAttribute("javax.servlet.error.status_code ");
String message = "异常信息: "+ request.getAttribute("javax.servlet.error.message ");
String type = "产生异常实例: "+ request.getAttribute("javax.servlet.error.exception_type ");
String uri = "导致问题产生的资源的URI字符串对象: "+ request.getAttribute("javax.servlet.error.request_uri ");
System.out.println(status_code + message + type + uri);
可是打印出来的值全为空,有哪位大牛帮忙一下?