为什么 Tomcat 运行时默认打开 index.html 或 index.jsp?如何配置首页?

本文详细解释了Tomcat为何默认加载index.html或index.jsp作为首页,并提供了如何通过修改web.xml文件来配置不同首页的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


1. 问题

  • 为什么 Tomcat 运行时默认打开 index.html,或者 index.jsp?如何配置首页?

2. 解答

  • 这个是 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>
  • 如果需要修改模块的欢迎页面也是可以的,只需要在当前模块的 web.xml 文件配置即可。
	<!--配置欢迎页面即可-->
    <welcome-file-list>
        <welcome-file>love.html</welcome-file>
    </welcome-file-list>
  • 补充说明:Tomcat 的安装目录下的 conf\web.xml 包含所有项目(模块)的配置信息,如果 IDEA 中的 web.xml 没有相关的配置信息,就运行 Tomcat 安装目录下的 conf\web.xml。

原文链接:https://qwert.blog.csdn.net/article/details/105521071

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值