发帖    主题    评论    推荐    标签    作者    订阅    查搜    注册   登陆   关注
 
面向对象 设计模式 领域驱动设计 企业架构 框架 开发教程 微服务 CQRS 扩展性 并发编程 事件溯源 分布式 SOA

关于servlet mapping

2003-07-10 16:21
赞助商链接

servlet 2.4 specification中说,
Upon receipt of a client request, the Web container determines the Web application
to which to forward it. The Web application selected must have the the longest
context path that matches the start of the request URL. The matched part of the URL
is the context path when mapping to servlets.
The Web container next must locate the servlet to process the request using
the path mapping procedure described below.
The path used for mapping to a servlet is the request URL from the request
object minus the context path and the path parameters. The URL path mapping
rules below are used in order. The first successful match is used with no further
matches attempted:
1. The container will try to find an exact match of the path of the request to the
path of the servlet. A successful match selects the servlet.

2. The container will recursively try to match the longest path-prefix. This is done
by stepping down the path tree a directory at a time, using the ’/’ character as
a path separator. The longest match determines the servlet selected.

3. If the last segment in the URL path contains an extension (e.g. .jsp), the servlet
container will try to match a servlet that handles requests for the extension.
An extension is defined as the part of the last segment after the last ’.’ character.

4. If neither of the previous three rules result in a servlet match, the container will
attempt to serve content appropriate for the resource requested. If a "default"
servlet is defined for the application, it will be used.


谁能给我讲讲这是什么意思?
我找遍了所有的书,包括Sun和O'REILLY的,没有一本书上讲过这些内容。看规范又不太明白,真是太累了。
谁能帮帮我,在这里先谢谢了!

2003-07-10 19:51

这段话对你学习Servlet没有任何帮助。

大意是说Web Container收到一个客户浏览器的请求之后,如何来确定应该是访问哪个servlet。

先是在URI中匹配web app的路径,然后在剩下的部分中把?后面带的参数剔除掉。

在web.xml里面每个Servlet都会有映射一个URL路径的,先看看能否映射到,如果映射不到,就挨个路径一直找下去,还找不到就看看有没有后缀匹配上的,如果这也没有的话,就看看web app定义的默认主页能不能匹配。

2003-07-11 10:45

非常感谢robbin!大概知道是什么意思了。

赞助商链接

赞助商链接

返回顶部

移动版 关于本站 使用帮助 联系管理员 最佳分辨率1366x768
OpenSource JIVEJDON Powered by JdonFramework Code © 2002-20 jdon.com