web.xml文件中的url-pattern是如何进行的?

来源:互联网 发布:初学瑜伽哪个软件好 编辑:程序博客网 时间:2024/05/17 06:03

在上一片blog中最后留下了这么一个问题。下面开始来解决。参考:

 

http://www2.roguewave.com/support/docs/leif/leif/html/bobcatug/7-3.html

http://foxty.javaeye.com/blog/39332

http://blog.chinaunix.net/u2/86974/showart_1776019.html

 

10.2 Specification of Mappings
In the web application deployment descriptor, the following syntax is used to define mappings:
• A string beginning with a '/' character and ending with a '/*' postfix is used as a path
mapping.
• A string beginning with a '*.' prefix is used as an extension mapping.
• All other strings are used as exact matches only
• A string containing only the '/' character indicates that servlet specified by the mapping becomes the "default" servlet of the application.

 

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

原创粉丝点击