What is the use of the sub-element Context in the Host in the Tomcat server.xml file? It seems that its function can be achieved without using this element, such as this
<Host name="localhost" appBase="/web/webapps"unpackWARs="true"
autoDeploy="true">
<Context path="" docBase="/ROOT"/>
<Context path="app2" docBase="/app2"/>
</Host>
There are two folders ROOT and app2 in my webapps directory. I can access the application
http://localhost:8080/app2/
like this, but if I remove the Context
<Host name="localhost" appBase="/web/webapps"unpackWARs="true"
autoDeploy="true">
</Host>
It can also be accessed in this way, so what is the use of this Context?
漂亮男人2017-06-12 09:29:53
There are several ways to deploy java web to tomcat
Package the project directly into the webapps directory. This method is relatively simple and convenient, but the disadvantage is that it is too rigid. The project can only be placed in webapps
Use the virtual path, which is the context node you mentioned here. This method is more flexible than the above method. The project can be placed anywhere on the hard disk. The deployment can be completed by configuring the context. If you need to cancel the deployment, just delete the configuration