welcome-file-list是web.xml中用来设置首页(也就是默认进去的页面)
在做老师发的war包时我发现有些包启动tomcat时可以直接进入首页,有些不能直接进入而是显示404 not found,而需要我手动添加/index.jsp才可以进入
然后我比较了一个可以直接进入首页一个显示404在web.xml的不同,发现在 welcome-file-list中有不同,如
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>default.htm</welcome-file>
</welcome-file-list>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
这两种不同的首页显示,后来了解到welcome-file-list是怎么工作的,是从第一个开始找web目录下是否存在这个文件,如果存在就直接打开页面,如果不存在的话继续向下寻找,以此类推,如果一直找不到的话,就会显示404 not found。