How to set up virtual directories and configure virtual paths in Tomcat 7.0

How to set up virtual directories and configure virtual paths in Tomcat 7.0

Tomcat7.0 sets virtual directory

(1) Currently, our website sites are placed in the default directory: tomcat/webapps/. However, in some cases, we need to put the site in other directories, for example: there is insufficient space on the disk where tomcat is located;

Or for unified management of the project, you want to put it in a specific directory instead of the default directory.

(2) Then we will use today's method to solve this problem (also modify the config/server.xml file):

(3) Find the server.xml file according to the picture below (open config-----server.xml in Notepad)

(4) After opening, scroll to the bottom and find the HOST

The red circled part is what you need to add

<Context> represents a single web application running on <Host>

A <Host> can have multiple <Context> elements. Each web application must have a unique URL path, which is set in the path attribute of <Context>.

Attributes of the <Context> element:

path: specifies the URL entry for accessing the Web application. The path must start with "/", otherwise an error will be reported.

docBase: specifies the file path of the Web application. You can give an absolute path or a relative path relative to the appBase attribute of <Host>. If the Web application uses an open directory structure, specify the root directory of the Web application. If the Web application is a war file, specify the path of the war file.

reloadable: If this property is set to true, the Tomcat server will monitor changes to class files in the WEB-INF/classes and WEB-INF/lib directories while running. If it detects that a class file has been updated, the server will automatically reload the Web application.

Setting the reloadable attribute to true during the development phase helps debug servlets and other class files, but this will increase the server load. It is recommended to set reloadable to false during the development and storage phase of a Web application.

For example, in my address bar, enter localhost:8080/lecheng in the address bar.

OK! Click here for a successful visit!

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • How to install and configure tomcat9 in Centos7 and set it to start automatically
  • IntelliJ IDEA Tomcat hot deployment configuration tutorial
  • How to configure tomcat to use both http and https for access
  • How to configure tomcat with Alibaba Cloud https certificate
  • Tomcat+Mysql high concurrency configuration optimization explanation
  • Spring Boot customizes and optimizes the built-in Tomcat container instance
  • How to optimize the embedded Tomcat example in Spring Boot
  • Detailed explanation of Tomcat configuration and optimization solutions

<<:  How to solve mysql error 10061

>>:  React tsx generates random verification code

Recommend

A brief introduction to Linux performance monitoring commands free

When the system encounters various IO bottlenecks...

mysql 5.7.11 winx64 initial password change

Download the compressed version of MySQL-5.7.11-w...

How to clean up the disk space occupied by Docker

Docker takes up a lot of space. Whenever we run c...

Summary of common functions and usage methods of WeChat applet development

Here, I have mainly sorted out some commonly used...

Detailed explanation of MySQL semi-synchronization

Table of contents Preface MySQL master-slave repl...

Solutions to Files/Folders That Cannot Be Deleted in Linux

Preface Recently our server was attacked by hacke...

Writing and understanding of arrow functions and this in JS

Table of contents Preface 1. How to write functio...

Several ways to encapsulate axios in Vue

Table of contents Basic Edition Step 1: Configure...

The role of nextTick in Vue and several simple usage scenarios

Purpose Understand the role of nextTick and sever...

Example of using CSS3 to create Pikachu animated wallpaper

text OK, next it’s time to show the renderings. O...

Double loading issue when the page contains img src

<br />When the page contains <img src=&qu...

Installation and use tutorial of Elasticsearch tool cerebro

Cerebro is an evolution of the Elasticsearch Kopf...