Tomcat:主机虚拟路径
1.在tomcat服务器:目录里有 **conf/server.xml 文件
server.xml 文件:里面有:下面代码:(我摘抄一些代码)
其中:
Host name=“localhost” appBase=“webapps”,是用localhost 代替了webapps
(真实路径)
所以我们:使用
http://localhost:8080/demo3_war_exploded/demo1
相对于:
D:\java web\apache-tomcat-8.5.72\webapps\demo3_war
这个真实路径
访问的是:自己目录下的:webapps目录下的demo3_war里面的
文件(可能是index.jsp,html文件.等等)
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Host name="localhost" appBase="webapps">
<Context path="/qqq" docBase="D:\java web\apache-tomcat-8.5.72\bbb"></Context>
</Host>
当你修改:
Host name=“localhost” appBase=“webapps”
修改为:
Host name=“wertyu” appBase=“webapps”
访问就要写:网址
http://wertyu:8080/demo3_war_exploded/demo1**
对比:只换了:localhost
http://localhost:8080/demo3_war_exploded/demo1