之前只知道welcome-file是用于配置首页地址,当访问域名时自动进入对应的页面,因此一直觉得这个配置的是一个绝对地址。最近在一次测试中发现输入一个没有配置nginx的地址居然能够进入一个页面,查了好久只有welcome-file这个最可疑,因而才去深扒它的说明(好吧,我认可我基础差)nginx
顺便吐槽下,查说明只有去英文网站才查到,中文的都是说怎么用.......web
This tag specifies the relative path of a single welcome file.服务器
A welcome file is provided when the web application is accessed using only the domain name, or with any other URL that ends with a slash.app
Welcome files must exist as physical files in your application, or in Servlets 2.4 and above can also be servlets that are defined in web.xml.dom
The page or servlet should be specified without any leading slash. Only relative paths can be specified.jsp
OK,了解了,也就是说welcome-file配置的是相对地址,当地址只有域名或是以斜杠结尾的时候,就会匹配到welcome-file中的相对地址里,举例说明:ide
web.xml配置:
测试
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list>
则www.baidu.com就会匹配为www.baidu.com/index.jsp网站
这也是最经常使用的你们都懂得code
但若是地址为www.baidu.com/admin,则会匹配为www.baidu.com/admin/index.jsp
这个容易被别人忽略,固然提早是没有被nginx、filter或服务器拦截到并且确实有admin/index.jsp这个文件
好了,记录一下以避免忘记,大神能够直接回复:然并卵......