4

【笔记】Tomcat配置Web应用缺省值

 2 years ago
source link: https://feiju12138.github.io/2022/08/01/Tomcat%E9%85%8D%E7%BD%AEWeb%E5%BA%94%E7%94%A8%E7%BC%BA%E7%9C%81%E5%80%BC/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Tomcat配置Web应用缺省值

配置容器的默认Web应用

  • webapp目录下创建一个目录ROOT,这个目录就是默认的Web应用

配置Web应用的默认主页

  • 修改配置文件
  • 如果配置文件没有配置<welcome-file-list></welcome-file-list>,那么会参考全局配置
  • 可以配置多条<welcome-file></welcome-file>,当第一条失效时,自动使用第二条的配置

index.html:首页路径

WEB-INF/web.xml

<?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>

全局配置中的默认主页配置

  • 修改全局配置文件的4737行~4741行

/opt/homebrew/etc/tomcat/web.xml

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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK