Summary of configuration methods for tomcat virtual paths

  • 2020-05-15 02:31:58
  • OfStack

Generally, we are directly referring to web project under webapps. If we want to deploy an WEB project in another place, we need to set the virtual path in TOMCAT. The order of Tomcat loading web is to load the xml file under Tomcat_home$\conf\Catalina\localhost (the path of web project is configured in the file), and then load the web project under webapps.

Suppose we want to deploy d:\project\ the XXX project below (XXX is the project name).

Here we have two ways:

Method 1: in the $$\ conf \ Catalina \ Tomcat_home localhost path under a new XML file, note: XML file name, that is, after the success of the project deployment web root path. If defined this test xml, then the access path behind is http: / / ip: port/test, file content is as follows:


<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="D:\project\XXX" reloadable="true" debug="0" path="/test"/>
 

Actually, path="/test" is not allowed here. In this case, path is actually determined by the name of the xml file, so it can be abbreviated as


<Context docBase="D:\project\XXX" reloadable="true" debug="0" />

This sets up the virtual path for /test

Method 2: edit server file (%tomcathome%\conf\ server.xml)
We intend to create a virtual directory of myjsp, just in %tomcathome%\conf\ server.xml file, in %tomcathome < host > Add the following code to the tag file:


<Context docBase="D:\project\XXX" reloadable="true" debug="0" path="/test"/>

Notice that path1 must be written at this point, because we're not creating a new xml file at this point, so 1 must specify web.

The meaning of profile properties:

debug should be 1 web debugging project java code, integrate tomcat server and development tools, or need tools 1 some plug-in support (such as under Eclipse myclipse, etc.), these methods are to be carried out at the local, namely your development tools and tomcat running on the same server, 1 if your development tools and server 1 machines that no longer needs to implement remote

Debugging function.

In fact, the log4j package will be introduced in the development of java project, and debugging information will be output in the development process in the way of configuration. If you don't have a specific requirement, it's not recommended to take the time to research it.

When reloadable=true, the relevant file changes. Tomcat first stops web app and frees the memory, and then reloads web app. This saves the time required to manually deploy the web app project. And development tool 1 can be used to slightly increase productivity.


Related articles: