What is the use of Tomcat Context
滿天的星座
滿天的星座 2017-06-12 09:27:53
0
2
686

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?

滿天的星座
滿天的星座

reply all(2)
大家讲道理

Have you configured this app2 in web.xml, so you can access it

漂亮男人

There are several ways to deploy java web to tomcat

  1. 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

  2. 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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template