web.xml中的welcome-file认识

以前只知道welcome-file是用于配置首页地址,当访问域名时自动进入对应的页面,所以一直以为这个配置的是一个绝对地址。最近在一次测试中发现输入一个没有配置nginx的地址竟然可以进入一个页面,查了很久只有welcome-file这个最可疑,于是才去深扒它的说明(好吧,我承认我基础差)

顺便吐槽下,查说明只有去英文网站才查到,中文的都是说怎么用.......

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.

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.

The page or servlet should be specified without any leading slash. Only relative paths can be specified.

OK,了解了,也就是说welcome-file配置的是相对地址,当地址只有域名或是以斜杠结尾的时候,就会匹配到welcome-file中的相对地址里,举例说明:

web.xml配置:

<welcome-file-list>
	<welcome-file>index.jsp</welcome-file>
</welcome-file-list>


则www.baidu.com就会匹配为www.baidu.com/index.jsp

这也是最常用的大家都懂得

但如果地址为www.baidu.com/admin,则会匹配为www.baidu.com/admin/index.jsp

这个容易被别人忽略,当然提前是没有被nginx、filter或服务器拦截到而且确实有admin/index.jsp这个文件


好了,记录一下以免忘记,大神可以直接回复:然并卵......

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值