web.xml的URL Patten

一.URL-Patten语法:
分三种情况:
1) 精确匹配:URL的字符和URL-Patten的字符完全匹配。
2) 通配符/*:匹配当前上下文环境下所有的请求
3) 通配符*.extension:匹配所有的跟extension扩展名相同的请求。
举例:
For example, a web.xml file for the examples context on the server at example.com matches the pattern

in <url-pattern>/status/*</url-pattern> as follows:

http://example.com/examples/status/synopsis
 Matches
 
http://example.com/examples/status/complete?date=today
 Matches
 
http://example.com/examples/status
 Matches
 
http://example.com/examples/server/status
 Does not match
 
A context located at the path /examples on the server at example.com matches the pattern in <url-

pattern>*.map</url-pattern> as follows:

http://example.com/examples/US/Oregon/Portland.map
 Matches
 
http://example.com/examples/US/Washington/Seattle.map
 Matches
 
http://example.com/examples/Paris.France.map
 Matches
 
http://example.com/examples/US/Oregon/Portland.MAP
 Does not match, the extension is uppercase
 
http://example.com/examples/interface/description/mail.mapi
 Does not match, the extension is mapi rather than map
二.Servlet 匹配过程
1)首先执行精确匹配.
2)再执行最长匹配
3)然后执行文件路径匹配
4)然后是扩展名匹配
5)最后是默认匹配
三.默认匹配
当没有任何模式可以匹配时,就会匹配以下格式的默认servlet,默认匹配一般会定向到应用的第一个页面,这样也可

以保证那些不合适的URL经过程序处理不返回错误页面。
格式:<url-pattern>/</url-patttern>

 

饿……第一次做翻译原来以为翻译是比较简单的,没想到自己看懂要把他们用中文表达出来还是如此的让人郁闷的,有想看原文的请点击以下链接:http://www2.roguewave.com/support/docs/leif/leif/html/bobcatug/7-3.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值