Java webapps - 为什么在访问 webapps 根目录时显示 index.html?

Java webapps - why is index.html displayed when visiting a webapps root directory?

假设您在本地主机的 Tomcat 上部署了一个名为 MyWebApp 的网络应用程序。如果您像这样使用浏览器访问它:

localhost:8080/MyWebApp

那为什么会显示index.html(假设.war文件中有index.html)?

是否有某处配置表明应通过发送 index.html 来响应对 /MyWebApp 的请求?是否可以更改该配置?为什么没有处理此请求的 servlet?

index.html 页面在 web.xml 文件中指定为欢迎页面。

看起来像这样:-

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

这就是您将 index.html 视为欢迎页面的原因。