1 / 4
文档名称:

Tomcat源码分析容器处理连接之servlet的映射.doc

格式:doc   大小:19KB   页数:4页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

Tomcat源码分析容器处理连接之servlet的映射.doc

上传人:1542605778 2022/1/29 文件大小:19 KB

下载得到文件列表

Tomcat源码分析容器处理连接之servlet的映射.doc

相关文档

文档介绍

文档介绍:Tomcat源码分析(五)--容器处理连接之servlet的映射
本文所要解决的问题:一个http请求过来,容器是怎么知道选择哪个具体servlet?
我们知道,一个Context容器表示一个web应用,一个Wrapper容器表示一个a]
public Container map(Request request, boolean update) {
// Identify the context-relative URI to be mapped
String contextPath =
((HttpServletRequest) ()).getContextPath();
String requestURI = ((HttpRequest) request).getDecodedRequestURI();
String relativeURI = (());
// Apply the standard request URI mapping rules from the specification
Wrapper wrapper = null;
String servletPath = relativeURI;
String pathInfo = null;
String name = null;
// Rule 1 -- Exact Match
if (wrapper == null) {
if (debug >= 2)
(" Trying exact match");
if (!(("/")))
name = (relativeURI);
if (name != null)
wrapper = (Wrapper) (name);
if (wrapper != null) {
servletPath = relativeURI;
pathInfo = null;
}
}
// Rule 2 -- Prefix Match
if (wrapper == null) {
if (debug >= 2)
(" Trying prefix match");
servletPath = relativeURI;
while (true) {
name = (servletPath + "/*");
if (name != null)
wrapper = (Wrapper) (name);
if (wrapper != null) {
pathInfo = (());
if (() == 0)
pathInfo = null;
bre