在web.xml文件中的web-app块的welcome-file-list子元素用于定义欢迎文件列表。 它的子元素是welcome-file,用于定义欢迎文件(即默认打开的页面)。
欢迎文件是服务器自动调用的文件,如果不指定任何文件名。
默认情况下,服务器按以下顺序查找欢迎文件:
web.xml文件中的welcome-file-list指定的文件index.htmlindex.htmlindex.jsp
如果没有找到这些文件,服务器会报告404错误。
如果在web.xml中指定了welcome-file,并且所有文件index.html,index.html和index.jsp都存在,那么优先级将转到welcome-file。
如果web.xml文件中不存在welcome-file-list项,那么优先级到index.html文件,然后是index.html,以及最后是index.jsp文件。
下面来看看一个定义欢迎文件的web.xml文件。
helloworld
index.html
index.jsp
home.jsp