Web站点的欢迎页面的设置
* 欢迎页面怎么设置?
- 假设在WebContent下创建login.html,想让login.html作为站点的欢迎页面。
- 打开web.xml文件,添加<welcome-file-list></welcome-file-list>标签,将该html文件引入。
<!-- 欢迎界面的设置 -->
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
<welcome-file-list>
<welcome-file> html/welcome.html </welcome-file>
<welcome-file> html/123.html </welcome-file>
</welcome-file-list>
- 为什么要设置欢迎页面?
1.为了访问更方便,设置欢迎页面之后,在浏览器地址栏输入Webapp地址自动定位到欢迎页面
- 欢迎页面的几点注意?
1.欢迎页面可以设置多个,越靠上优先级越高。找不到会依次向下寻找。
2.欢迎页面也可以是一个Servlet,不一定是HTML,可以是任何一种类型的Web资源
3.欢迎页面路径设置的时候不需要以/开始。
4.在Tomcat中conf中默认的web.xml文件中已经设置好了默认的欢迎界面,所以在Web中的web.xml文件中不设置欢迎界面,只要新建一个index.html就会成为欢迎界面。
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>