简体   繁体   English

如果tomcat的web.xml中没有欢迎文件列表怎么办?

[英]what if there is no welcome file list in web.xml in tomcat?

Generally, welcome file lists are used to show first page of application. 通常,欢迎文件列表用于显示应用程序的首页。 What if, in my web.xml i don't have welcome file lists. 如果在我的web.xml中没有欢迎文件列表怎么办。 In this case, which file will be shown as home page of my application? 在这种情况下,哪个文件将显示为我的应用程序的主页? I just have few filters in web.xml? 我在web.xml中只有几个过滤器?

Just a HTTP 404 error page will be shown, which can be either the servletcontainer's default one or the one which you definied as <error-page> for <error-code>404</error-code> in web.xml . 仅显示一个HTTP 404错误页面,该页面可以是servlet容器的默认页面,也可以是您在web.xml<error-code>404</error-code> <error-page>

Or, if the servletcontainer is configured to show directory listings by default, then it will be shown instead. 或者,如果servlet容器默认配置为显示目录列表,则将显示它。 In Tomcat, it's configureable as listings init param of the default servlet in /conf/web.xml . 在Tomcat中,可以将其配置为/conf/web.xml默认servlet的listings init参数。

Or, if you have a (poorly designed?) servlet or filter which is been mapped on /* or / and does not do its job properly, then you will see its response body instead. 或者,如果您有一个(设计不当?)servlet或过滤器,该servlet或过滤器映射到/*/并且不能正确执行其工作,那么您将看到其响应正文。

If you experiment a bit and try it yourself, then you'll see it yourself as well. 如果您尝试一下并自己尝试,那么您也将自己看到它。 Here's a screen of Tomcat's default HTTP 404 error page: 这是Tomcat的默认HTTP 404错误页面的屏幕:

在此处输入图片说明

And here's a screen of Tomcat's default directory listing: 这是Tomcat默认目录列表的屏幕:

在此处输入图片说明

This answer might be specific to Tomcat 7 Server. 该答案可能特定于Tomcat 7服务器。

If you do not define Welcome Pages, Tomcat 7 looks for the following files in the following order and serves the first one it finds: 如果未定义欢迎页面,则Tomcat 7将按以下顺序查找以下文件,并提供找到的第一个文件:

index.html, index.htm, index.jsp index.html,index.htm,index.jsp

So if none of the above files are present, a HTTP Status 404 error is thrown. 因此,如果以上文件均不存在,则会引发HTTP Status 404错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM