天天看点

如何将tomcat默认页面换成项目首页?

问题分析

安装好tomcat以后,我们输入网址(或者ip),访问到tomcat(默认端口为8080),浏览器当中出现的是tomcat的欢迎界面,如下:
如何将tomcat默认页面换成项目首页?

那么如何能够输入地址以后能够访问到我们自己发布的默认欢迎界面呢?方法如下:

1.首先找到tomcat的目录的conf文件夹

如何将tomcat默认页面换成项目首页?

2.找到server.xml,打开并编辑

如何将tomcat默认页面换成项目首页?

3.找到文件中的Host节点

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

  <Context crossContext="true" docBase="项目地址路径" path="" reloadable="true" />
       
 
        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
 
      </Host>      

4.将tomcat的默认端口8080改为80

如何将tomcat默认页面换成项目首页?

5.确保项目中的web.xml中有如下代码

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