tomcat <context path>的意义及作用

context path 是在tomcat 要支持多个应用时对每个应用的docBase做区别时的区分符。

打个比方假如你有两个请求:一个为 http:localhost:8080/test1/helloworld  另外一个为 http:localhost:8080/test2/helloworld

这时候你的

     第一个请求 context的配置为 <context path="test1" docBase="~/Documents/web1/" reloadable = true>

     第二个请求的 context的配置为 <context path="test2" docBase="~/Documents/web2/" reloadable = true>

第一个请求的path为 "test1",其对应的docBase路径是~/Documents/web1/,tomcat服务器在接收到请求后就会从这个~/Documents/web1/路径去调用某个class的用来处理请求 http:localhost:8080/test1/ 这种格式url请求

请求的path为 "test2",其对应的docBase路径是~/Documents/web2/,tomcat服务器在接收到请求后就会从这个~/Documents/web2/路径去调用某个class的用来处理请求 http:localhost:8080/test2/ 这种格式url请求

(假如你没有指定path,但是指定了docBase的时候这时候你访问的url不用带/path 就可以访问到docBase的服务了,如<context path="" docBase="~/Documents/web1/" reloadable = true>,访问url:http:localhost:8080/helloworld)

原文地址:https://www.cnblogs.com/codetime/p/5325509.html