Tomcat Configuration virtual Directory--<context> tags

Source: Internet
Author: User

After the default installation,Tomcat's home directory is the Webapps/root directory, if we want to changeTomcat's home directory can do this:

1. Open C: \Tomcat\conf\server. XML, add code between
<context path= "/" docbase= "E:\tomcatApp\JeasyCMS" debug= "0" reloadable= "true" crosscontext= "true"/>
Path is the virtual path, access time, note: Be sure to add "/"
Debug recommended setting to 0,reloadable is set to true.

This restartsTomcat, our home directory is set to jeasycms this project.

2. In additionTomcat will generate a C \Tomcat\conf\catalina\localhost directory, which automatically generated a root.xml (root capitalization) file, we open the file can see the code:

<? XML version= ' 1.0 ' encoding= ' utf-8 '?>
<context crosscontext= "true" docbase= "E:/tomcatapp/jeasycms" path= "" reloadable= "true" >
</Context>

3. Note: This is also the case when we create the virtual directory, so that the path property of the context tag is not empty.

4. We set up both the virtual directory and the home directory in C: \The corresponding XML file is generated under the Tomcat\conf\catalina\localhost directory, so when we are in server. The XML inside the home directory and the virtual directory to delete the settings, if the system has not yet taken effect, this time we have to check the directory of the XML file has been deleted, if not deleted, he stillTomcat works, we have to delete it manually.

5. Based on the 4th, passing the test I found that whenever we visited an address,Tomcat first is to C #tomcat\conf\catalina\ localhost directory down to see if there is a home directory or virtual directory of the XML file, if there is an XML file, the path in the XML to access, if there is no XML file, to the server. XML file to see if the context tag is configured, and if the context tag is configured, the C \tomcat\conf\catalina\ the localhost directory to generate a corresponding XML file, so that the next direct authentication and no longer access to the server. XML, while opening the context in the specified path, if the server. The context tag is not configured in the XML, then the Access error page is returned.  

6. Based on the 5th, we can actually create an XML file directly under C:\tomcat\conf\catalina\localhost, Used for the home directory or virtual directory without the need to modify the server. XML can be configured to configure the home directory and the purpose of the virtual directory, the format of the specific XML can be as follows:

<? XML version= ' 1.0 ' encoding= ' utf-8 ',
<context crosscontext= "true" docbase= "E:/tomcatapp/jeasycms" path= "" Reloadable= "true";
</context>

Whether the configuration of the home directory or the configuration of the virtual directory depends on the value of path. In addition, the home directory filename must be root.xml (root capitalization), and the virtual directory's file name and virtual directory name are consistent and lowercase, for example:  

< XML version= ' 1.0 ' encoding= ' utf-8 ',
<context crosscontext= "true" docbase= "e:/tomcatapp/jeasycms" path= "\ CMS "reloadable=" true ";
</context>

The above defines a virtual directory named CMS and saves the above text as a CMS. XML file.

7. The above list of live directories can be accessed at the following address:

http://localhost:8080/(Access home directory)

Http://localhost:8080/cms ( Access to a virtual directory named CMS

Tomcat Configuration virtual directory--<context> tags

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.