Tomcat如何找到我的Web应用程序的主页?

Van*_*aff 29 tomcat web-applications

我刚开始学习Web应用程序并将它们部署到Tomcat.所以我开始使用一个示例Web应用程序项目 - 由struts,hibernate等组成,等等.

ANT构建成功.此外,能够通过Catalina/host下的xml部署Web应用程序.我能够毫无问题地打开网站.

这是我的网络应用程序的结构

-exploded

     -WEB-INF

          -classes

          -lib

          -web.xml

    -index.jsp

    -welcome.html
Run Code Online (Sandbox Code Playgroud)

我的问题是

Tomcat如何知道它应该打开的第一页/起始页/主页?指定了哪个文件?

Jos*_*seK 49

在任何Web应用程序,会有一个web.xmlWEB-INF/的文件夹.

如果您的Web应用程序中没有一个,因为在您的文件夹结构中似乎就是这种情况,默认的Tomcat web.xml就在TOMCAT_HOME/conf/web.xml

无论哪种方式,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>
Run Code Online (Sandbox Code Playgroud)

所以找到匹配此模式的任何文件都将显示为主页.

在Tomcat中,Web应用程序中的web.xml设置将覆盖默认值(如果存在).

进一步阅读

如何覆盖Tomcat加载的默认主页?