tomcat 设置path 访问路径

v-lhb-app01:/usr/local/apache-tomcat-7.0.55_8083/conf> cat server.xml | tail -10
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
		<Context docBase="zjzc-web-pay" path="" reloadable="false"/>
      </Host>
    </Engine>
  </Service>
</Server>



v-lhb-app01:/usr/local/apache-tomcat-7.0.55_8083/webapps/zjzc-web-pay> cat index.html 
<html>
<body>
<h2>Hello 22222-2aaaaaaaaaa--zjzc-pay-aaaaaaaaa!</h2>
</body>
</html>



</html>v-lhb-app01:/usr/local/apache-tomcat-7.0.55_8083/webapps> ls
1  docs  examples  host-manager  index.html  manager  zjzc-web-pay  zjzc-web-pay.zip


根目录下有个Index.html  应用目录下 也有Index.html 所以会进去到zjzc-web-pay去查找 index.html 


可以通过访问:
http://192.168.32.113/

这里的path没有指定:

v-lhb-app01:/usr/local/apache-tomcat-7.0.55_8083/conf> tail -10 server.xml
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
		<Context docBase="zjzc-web-pay" path="/api" reloadable="false"/>
      </Host>
    </Engine>
  </Service>
</Server>


设置path为/api:


http://192.168.32.113/api/ 可以访问:

此时http://192.168.32.113/ 无法访问



原文地址:https://www.cnblogs.com/hzcya1995/p/13351711.html