ContextPath Servletpath pathinfo的一些问题

An HTTP request URL contains the following parts:

http://[host]:[port][request-path]?[query-string]

The request path is further composed of the following elements:

  • Context path: A concatenation of a forward slash (/) with the context root of the servlet’s web application.

  • Servlet path: The path section that corresponds to the component alias that activated this request. This path starts with a forward slash (/).

  • Path info: The part of the request path that is not part of the context path or the servlet path.

----------------

1.容器试图在web.xml中寻找匹配的请求URI。如果找到了,完整的请求URI(除去context路径)即servlet路径。
这时HttpServletRequest.getPathInfo()为null
2.使用/作为分隔符,将请求URI转化为目录树,并通过递归匹配web.xml中URL-PATTERN,获得最长的匹配路径.匹配部分即servlet path
其余为path info
3.如果请求URI的最后一个节点包含一个扩展名(如:.jsp),servlet容器会将它和处理这个种特定的扩展名servlet匹配.
这时, 完整的请求URI, 减去context path即servlet path, 并path info为null.
4.如果容器仍然不能匹配请求路径, 它会将请求forward到默认的servlet.如果没有默认的servlet, 它会发送一条说明服务器没有找到
指定文件未找到的错误信息(404)

 

----------------------

Context path: /lostyue, Servlet path: /index.html, Path info: null
Context path: /lostyue, Servlet path: /css/jquery-ui.css, Path info: null
Context path: /lostyue, Servlet path: /js/jquery.js, Path info: null
Context path: /lostyue, Servlet path: /js/jquery-ui.js, Path info: null
Session Destoryed! ---2012-03-14 21:01:22
Context path: /lostyue, Servlet path: /jsp/displayname.jsp, Path info: null

 

我在filter中打印这些信息的时候,在载入默认主页时,打印了一些script信息,有些不能理解。是不是涉及到js的一些处理?

这个和url-pattern是不是有些关系? 有待深入。

另外默认的访问页都是Index.html

 

转载于:https://www.cnblogs.com/lostyue/archive/2012/03/14/2396593.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值