修改TOMCAT默认主页

1、默认的项目都在目录:apache-tomcat-9.0.0.M22webappsROOT下

2、该目录下有一个index.jsp是tomcat的默认主页,如下

3、现在需要修改这个默认主页,改成自己的主页

(1)修改配置文件server.xml(在conf目录下),找到如下代码:

<Host name="172.18.0.5"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
<Context path="" docBase="C:apache-tomcat-9.0.0.M22webappsROOT"/>

 修改第三行为<Context path="" docBase="C:apache-tomcat-9.0.0.M22webappsROOT1" debug="0"/>

其中C:apache-tomcat-9.0.0.M22webappsROOT1就是你想设置的网站根目录,我这里的根目录就是1

(2)修改配置文件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>

在第一行添加上指定文件,如<welcome-file>work_detail.html</welcome-file>,注意:work_detail.html是目录1下的文件

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

4、重启tomcat,访问172.18.0.5:8080

OK,访问的根目录就是刚刚设置的目录文件了

原文地址:https://www.cnblogs.com/ermao0423/p/9639806.html