1、欢迎页面怎么设置
假设在webroot目录下编写login.html,想让login.html作为整个webapp的欢迎页面,则需要编写web.xml
<welcome-file-list><welcome-file>login.html</welcome-file></welcome-file-list>
假设在webroot目录下创建html目录,在html目录下编写login.html,想让login.html作为整个webapp的欢迎页面,则需要编写web.xml
<welcome-file-list> <welcome-file>html/login.html</welcome-file> </welcome-file-list>欢迎页面可以设置多个,越靠上面的优先级越高。以下配置,优先选择login.html作为欢迎页面,若是该资源不存在,才会考虑html/login.html作为欢迎页面。
<welcome-file-list> <!--注意点:欢迎页面设置的时候不需要以“/”为开始--> <!--要求在webapp根目录下必须有一个文件login.html--> <welcome-file>login.html</welcome-file> <!--要求在webapp根目录下必须有一个文件夹html,该文件夹下必须有一个文件叫做login.html--> <welcome-file>html/login.html</welcome-file> </welcome-file-list>一个webapp的欢迎页面不一定是一个html,可以是任何一种类型的web资源,也可以是一个servlet,只需如下设置即可:
2、为什么设置欢迎页面?
- 方便用户访问
- 设置欢迎页面之后,直接在浏览器地址栏访问呢该webapp即可,例如:http://localhost:8080/prj-servlet-06,如此直接访问的就是login.html
3、全局配置和局部配置



