gpt4 book ai didi

java - 如何指定此 Spring MVC 演示应用程序中显示的第一页是什么?

转载 作者:行者123 更新时间:2023-12-01 12:00:29 25 4
gpt4 key购买 nike

我正在学习 Spring Core 认证,并且对 Spring MVC 使用有疑问。

我有一个演示网络应用程序。当我在 TomCat 服务器上运行它时,它会自动在浏览器中打开此 URL:

http://localhost:8080/mvc/

显示网页。

在类(class)幻灯片上阅读它说:

Once deployed, navigate to the index page at http://localhost:8080/mvc. You should see the index page display

好吧,我找不到有关必须作为 web 应用程序入口点打开的主页的信息,但我在文件夹中找到了 index.html 文件:/mvc/src/main/webapp/index.html

所以我的疑问是:webap文件夹是一个可能包含我的 View 的文件夹(web应用程序的其他jsp View 位于此文件夹的某个子目录中),所以如果我在这里放置一个< strong>index.html 文件,它在 Web 应用程序启动时默认打开,而不需要我指定一个欢迎文件或类似的文件?

Tnx

最佳答案

欢迎文件机制在servlet specifications中指定。 (servlet 3.0 版本的第 10.10 节)。和Spring没有太大关系。

对于 Tomcat,如果您未在 Web 应用程序描述符中指定任何欢迎文件,则会使用默认配置(存在于 tomcat 的 conf/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>

这意味着Tomcat将使用这3个文件作为欢迎文件。

关于java - 如何指定此 Spring MVC 演示应用程序中显示的第一页是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28012017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com