tomcat 7 conf / web.xml自定义错误页面未被webapps选中

时间:2014-06-24 15:51:43

标签: java tomcat centos

我正在tomcat 7(CentOS 5)中设置自定义404页面。

<error-page> 
    <error-code>404</error-code>
    <location>/error/404.html</location>
</error-page>

现在的问题是

localhost:8080/badlink displays 404.html

但在使用webapps / sample

localhost:8080/sample/badlink displays a blank page 

/ sample / badlink的日志显示

 FINE: Processing ErrorPage[errorCode=404, location=/error/404.html]

我认为tomcat会选择自定义404页面,但它并没有提供给浏览器。 是因为错误/ 404.html放在webapps / ROOT中,所以其他webapps没有访问它 有什么想法吗?

1 个答案:

答案 0 :(得分:0)

这是一个简单的问题,每个安装的webapp都应添加error / 404.html。因此使用文件的冗余副本而不是单个全局文件,即

/usr/tomcat/webapps/sample/error/404.html
/usr/tomcat/webapps/ROOT/error/404.html
..

我找不到任何替代方案。

相关问题