5
回答
HttpServletRequest.getContextPath()和ServletContext.getContextPath()
【腾讯云】学生服务器套餐10元/月 >>>   

    看了一下api,没弄懂两者之前的区别是什么,大多数情况下我发现两者得到的结果是一样的,api这样说:

It is possible that a servlet container may match a context by more than one context path. In such cases the HttpServletRequest.getContextPath() will return the actual context path used by the request and it may differ from the path returned by this method. The context path returned by this method should be considered as the prime or preferred context path of the application.
字面上了解了,但是具体有什么不同还是不知道,那么哥可以说下什么情况下两者返回的是不同的呢?

<无标签>
举报
顶部