Tomcat sets the virtual directory method without modifying the SERVER.XM

Source: Internet
Author: User

The team used this form of development, so switch the development environment, test environment, the formal environment only need to modify the Project.xml file on the line. The Project.xml name is arbitrary and is accessed using the name when it is accessed.

In the Tomcat folder, Conf\catalina\localhostAdding project. xml file contents: <context path= "/project" reloadable= "true" docbase= "E:\javastudio\oob" workdir= "e:\ Javastudio\oob\work "/>
    • Docbase is the top-level directory of the Web-inf folder of the project folder
    • Workdir refers to the Tomcat parsing JSP into a Java file, and compiled into a class folder, set in the project folder, you can avoid porting to other places for the first time to read the JSP file needs to be re-parsed. General Format: project folder \work
    • Reloadable refers to the ability to reload, which is generally set to truefor ease of use and does not require frequent reboots of Tomcat.
After you start Tomcat, you can access the project's welcome file by entering Http://localhost:8080/project in the browser. Why not modify Server.xml?       In Tomcat6 's Doc help document, the official does not advocate modifying Server.xml to add virtual directories! And I think, the above method, very convenient for the project transplant, after the transplant, only modify docbase and Workdir values on the line, can even remove Workdir this attribute!

***************

And I found a good article.

Transferred from: http://blog.csdn.net/yiluoak_47/article/details/12503737

First, we need to know the benefits of virtual directories. The virtual directory is different from the original Tomcat run, the original way is to copy the project to WebApps, and then start Tomcat, you can access the project under WebApps. We use Eclipse to configure Tomcat, which is actually the way it works.

However, the disadvantage of this approach is that the project under WebApps is not up-to-date, and once we have modified the project under the Eclipse working directory, we cannot immediately react to Tomcat/webapps. So we had to compile the project, clear the cache under WebApps, even remove the project, and then put it in. This kind of back and forth toss, greatly reduces the work efficiency. As long as we change a small place, we should repeat the work above.

A wise man is always lazy. Can we think of a better way to change the way we are today? This is when the virtual directory emerges.

The purpose of the virtual directory is to direct the Web publishing directory directly to the Eclipse working directory, real-time updates, real-time use.

To configure the virtual directory, we need to name "project name. xml" under Tomcat/conf/catalina/localhost under the project, and the contents:

<?xml version= "1.0" encoding= "UTF-8"?> <context path= "/cecb2b" docbase= "E:\workspace\cecb2b\webContent" Workdir= "E:\workspace\cecb2b\word" reloadable= "true" debug= "1" ></Context>

Attribute Explanation:

Path: Network access name

DocBase: Actual project path

Worddir: Specifies the directory where the JSP is converted to Java. Configure this so that the JSP is not recompiled when it is migrated

Reloadable: Specifies whether to reload when the class file changes

Debug: Whether it is a debug mode

In this way, the Web publishing directory points directly to the project under the Eclipse working directory. We modify the code under Eclipse, and as soon as one builds, Tomcat reloads automatically. We don't have to go back and forth to remove the project.

Finally, we can also modify the Cong/web.xml in:

        <init-param>            <param-name>listings</param-name>            <param-value>false</ Param-value>        </init-param>

Change False to True.

Finally, we need to note that creating a Web project with Eclipse must be a dynamic Web project, and then modify some of the properties of the project:

1. Remove Project--build automatically (auto build)

2, attribute--builders--except Java Builder all tick (so that project construction speed greatly accelerated).

3. Attribute--java Build path--source--project name/webcontent/web-inf/classes

Note that the tomcat7.0 differs from the previous:

<context path= "/vsearch" docbase= "E:/workspace/vsearch2012/webcontent" reloadable= "true" debug= "5" crossContext= "True"/>

Be aware that the XML file name must be the same as the name of path!

Tomcat sets the virtual directory method without modifying the SERVER.XM

Related Article

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.