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

The front end creates and modifies CAD graphics details through JavaScript

Table of contents 1. Current situation 2. Create ...

Detailed steps for using jib for docker deployment in Spring Cloud

Introduction to Jib Jib is a library developed by...

Set the input to read-only via disabled and readonly

There are two ways to achieve read-only input: dis...

Detailed explanation of MySQL Strict Mode knowledge points

I. Strict Mode Explanation According to the restr...

How to use rem adaptation in Vue

1. Development environment vue 2. Computer system...

XHTML introductory tutorial: Web page Head and DTD

Although head and DTD will not be displayed on th...

How to invert the implementation of a Bezier curve in CSS

First, let’s take a look at a CSS carousel animat...

Vue-Element-Admin integrates its own interface to realize login jump

1. First look at the request configuration file, ...

Website Design Experience Summary of Common Mistakes in Website Construction

Reminder: Whether it is planning, designing, or de...

How to implement import and export mysql database commands under linux

1. Export the database using the mysqldump comman...

jQuery achieves seamless scrolling of tables

This article example shares the specific code of ...

JavaScript implements single linked list process analysis

Preface: To store multiple elements, arrays are t...