1.如何设置一个网站的欢迎页面
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
注意:设置欢迎页面的时候,不需要加“/”,默认从webapp的根下开始查找。
2.如何设置多个欢迎页
<welcome-file-list>
<welcome-file>/page2/page3/login.html</welcome-file>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
注意:这个里面优先等级越靠上等级越高。
3.为什么文件名为index.html时,不需要配置欢迎页面
配置欢迎页面有两个地方可以配置:
1.在webapp内部的web.xml文件中。(在这个地方配置的属于局部配置)
2.在CATALINA_HOME/conf/web.xml文件中进行配置。(在这个地方配置的属于全局配置)
按照路径打开tomcat服务器的配置文件,发现了下面的配置信息。
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
Tomcat服务器的全局欢迎页面是:index.html index.htm index.jsp。
如果你一个web站点没有设置局部的欢迎页面,Tomcat服务器就会以index.html index.htm index.jsp作为一个web站点的欢迎页面。