我正在尝试根据状态代码重定向到其他错误jsp
statusCode = (Integer) req.getAttribute("javax.servlet.error.status_code")
但它抛出一个空指针错误。我的web.xml看起来像
<exception-type>404</exception-type><location>/AppExceptionHandler</location>
我认为web.xml
中的条目不正确。它应该像下面这样。异常类型不应该是代码,而应该是下面的类。
异常类型包含完全限定的类Java异常类型的名称。
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/AppExceptionHandler</location>
</error-page>
如果您想处理404
,请执行以下操作。
<error-page>
<error-code>404</error-code>
<location>/AppExceptionHandler</location>
</error-page>
sdvfvth rthgtr汞柱rtgwfrgbvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvcsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzzzertttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttgvsazdfv DFV