如何修改Tomcat服务器默认首页

当我们在使用Tomcat服务器开发网站时,配置好Tomcat服务器后输入连接访问的都是Tomcat服务器的默认首页,那么我们要如何才能修改Tomcat服务器的默认首页是我们自己的项目呢?

  1. 打开Tomcat服务器安装路径找到conf下的server.xml文件。

  2. 编辑server.xml文件

    在<host>节点中插入<Context path="" docBase="项目路径" debug="0" reloadable="true"/>,其中docBase为你所需要显示的默认项目的路径,也就是放在webapps文件下的项目名称,

    例如

    <Context path="" docBase="boke" debug="0" reloadable="true"/> //其中boke为你想要显示的默认项目
  3. 打开Tomcat服务器安装路径找到conf下的web.xml文件。

  4. 在<welcome-file-list></welcome-file-list>中添加你项目中的默认首页,代码如下:

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

    6.  重启服务器

重启服务器后再在浏览器中打开链接默认就会显示boke项目下的test.html网页。

猜你喜欢

转载自blog.csdn.net/qq_41286145/article/details/80645370