【问题标题】:Apache tomcat <error-page> tag in conf/web.xml not rendering an error pageconf/web.xml 中的 Apache tomcat <error-page> 标记未呈现错误页面
【发布时间】:2018-01-17 05:09:33
【问题描述】:

在 /conf/web.xml 中我提到了一个标签,如下所示:

 <error-page>
    <exception-type>401</exception-type>
    <location>/error.jsp</location>
</error-page>
<error-page>
    <exception-type>403</exception-type>
    <location>/error.jsp</location>
</error-page>
<error-page>
    <exception-type>404</exception-type>
    <location>/error.jsp</location>
</error-page>
<error-page>
    <error-code>500</error-code>
    <location>/error.jsp</location>
</error-page>
<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/error.jsp</location>
</error-page>

在此之前我也提到过

<error-page>
    <exception-type>404</exception-type>
    <location>/error.jsp</location>
</error-page>

但它仍然呈现相同的tomcat默认页面,而不是自定义的“error.jsp”页面。自过去 13 小时以来,我一直陷入这个问题。

【问题讨论】:

  • 您是否停止并重新启动了 Tomcat?

标签: java xml apache jsp tomcat


【解决方案1】:

尝试使用 error-code 而不是 exception-type

<error-page>
    <error-code>403</error-code>
    <location>/error.jsp</location>
</error-page>

【讨论】:

  • 感谢您的回复。实际上,我已经将页面“error.jsp”直接保存在 /conf 中,并且它没有被渲染。你能告诉我我应该把error.jsp保存在哪里,以便在404(找不到页面)时呈现它
  • 网址更新了吗?
  • 现在它工作正常。实际上我们必须把error.jsp放在tomcat的ROOT目录下。感谢您的回复。我犯了一个愚蠢的错误,使用 代替 。谢谢
猜你喜欢
  • 2014-08-14
  • 2017-11-11
  • 1970-01-01
  • 2014-04-18
  • 1970-01-01
  • 1970-01-01
  • 2012-07-30
  • 2013-09-29
相关资源
最近更新 更多