【问题标题】:Java webapps - why is index.html displayed when visiting a webapps root directory?Java webapps - 为什么在访问 webapps 根目录时显示 index.html?
【发布时间】:2015-12-11 18:33:37
【问题描述】:

假设您有一个名为 MyWebApp 的 Web 应用程序部署在 Tomcat 的 localhost 上。如果您像这样使用浏览器访问它:

localhost:8080/MyWebApp

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

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

【问题讨论】:

  • 欢迎文件在 web.xml 中定义。您可以设置其他欢迎文件。

标签: java tomcat servlets web-applications


【解决方案1】:

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

看起来像这样:-

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-13
    • 2012-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-30
    • 2011-10-09
    • 1970-01-01
    相关资源
    最近更新 更多