我已经为web.xml中的404和500个错误页面设计了两个网页
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/error/404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/error/500.jsp</location>
</error-page>对于所有其他错误,我想重定向到预先指定的页面。
请帮帮忙。谢谢
发布于 2017-11-16 06:40:08
这应该足够了,除了很少与客户错误相关的页面外,您还可以添加默认页面。因此,除404、500以外的所有错误都将重定向到泛型页error.html。
<error-page>
<location>/error.html</location>
</error-page>或者使用异常类进行更多的定制,也可以是您的自定义异常类。
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.html</location>
</error-page>所以代码变成,
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/error/404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/error/500.jsp</location>
</error-page>
<error-page>
<location>/error.html</location>
</error-page>https://stackoverflow.com/questions/47323154
复制相似问题