Original address: http://www.cnblogs.com/jams742003/archive/2009/06/04/1496133.html
The first of these methods
Set the virtual directory "MyWeb" to access the contents of the physical Path L:\java\JWeb folder through Http://localhost:8080/myweb. The setup process is as follows:
1. Copy the Web-inf folder under the Tomcat6.0\webapps\root directory to the L:\java\JWeb directory.
2. Open the Web.xml file under the L:\java\JWeb\WEB-INF directory and add after </description>:
<!--jspc servlet mappings Start-->
<!--jspc servlet mappings End-->
3. Open the Tomcat6.0\conf\server.xml file and add between <Host> and </Host>:
<context path= "/myweb" docbase= "L:\java\JWeb" ></Context>
Path= "/myweb" is the name of the virtual directory
docbase= "L:\java\JWeb" > For physical path
4. Open the Tomcat6.0\conf\web.xml file and find:
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
Set false to True to save, restart Tomcat, and now you can apply the Http://localhost:8080/myweb virtual directory.
The second method:
Find the Catalina\localhost directory in tomcat\conf
If it does not exist, it is created manually
The catalog is now:
Tomcat\conf\catalina\localhost\
Add custom profile (for example, my virtual directory name is: myweb), so the profile name is Myweb.xml (the name is arbitrary, same as the virtual directory name, is easy to maintain)
The contents of the configuration file are as follows:
<context
Path= "/myweb" <!--this part/after string should be the same as the filename, that is myweb=myweb-->
Docbase= "L:\java\JWeb" <!--this path is the physical address of the virtual directory, and the following three parameters are not explained-->
Reloadable= "true"
debug= "0"
Workdir= "L:\java\JWeb\work" >
</Context>
After setting up, access to http://localhost: Port/myweb/*.jsp can
I am using the second method. My situation is Tomcat decentralized many projects, divided into two categories by function, so I built two directories under Tomcat: "Dira" and "DIRB", Tomcat Server.xml under the appbase of the node is directed to Dira, So all the war packages under Dira will be automatically decompressed when Tomcat starts. Because it is in the local Area network test environment, cannot increase <Host> the virtual host, but also has one kind of project I want to put in the DIRB, because has not configured the virtual host again, DIRB the war package cannot automatically decompress also cannot access, therefore I wanted to build the virtual directory the way to deploy. Just <Context> the docbase of the node can point directly to the war package, so the war package under DIRB can be accessed directly through the virtual directory without decompressing.