一.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