【英文】Tomcat配置Web应用缺省值

Preface

Default configuration of Tomcat for web applications

Configuring the default web application for the container

  • Create a directory named ROOT under the webapp directory, which will serve as the default web application.

Configuring the default homepage for the web application

  • Modify the configuration file.
  • If the configuration file does not include <welcome-file-list></welcome-file-list>, it will refer to the global configuration.
  • Multiple <welcome-file></welcome-file> can be configured. When the first one fails, the second one will be automatically used.

index.html: path of the homepage

WEB-INF/web.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0"
metadata-complete="true">

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>

</web-app>

Default homepage configuration in the global configuration

  • Modify lines 4737 to 4741 in the global configuration file.
/opt/homebrew/etc/tomcat/web.xml
1
2
3
4
5
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Done