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

jQuery plugin to implement minesweeper game (3)

This article shares the third article on how to u...

Summary of Linux file directory management commands

touch Command It has two functions: one is to upd...

Summary of some common methods of JavaScript array

Table of contents 1. How to create an array in Ja...

About the layout method of content overflow in table

What is content overflow? In fact, when there is ...

The difference between Display, Visibility, Opacity, rgba and z-index: -1 in CSS

We often need to control the hidden, transparent ...

Detailed tutorial on installing Tomcat8.5 in Centos8.2 cloud server environment

Before installing Tomcat, install the JDK environ...

Vue sample code for implementing two-column horizontal timeline

Table of contents 1. Implement the component time...

HTML/CSS Basics - Several precautions in HTML code writing (must read)

The warning points in this article have nothing t...

Use mysql to record the http GET request data returned from the url

Business scenario requirements and implementation...

Web Design Tutorial (1): Steps and Overall Layout

<br /> Note: All texts, except those indicat...

Let's learn about JavaScript object-oriented

Table of contents JavaScript prototype chain Obje...

Steps to split and compress CSS with webpack and import it with link

Let's take a look at the code file structure ...