它如何指定在这个Spring MVC演示应用程序中显示的第一页是什么?

时间:2015-01-18 16:27:35

标签: java spring spring-mvc

我是Spring Core认证的老手,我对Spring MVC的使用存在疑问。

我有一个演示webapp。当我在TomCat服务器上运行它时,它会自动将此URL打开到浏览器中:

http://localhost:8080/mvc/

显示网页。

阅读课程幻灯片时说:

  

部署后,导航到索引页面   http://localhost:8080/mvc。您应该看到索引页面显示

好的,我找不到关于必须作为我的webapp的入口点打开的主页的信息,但我在文件夹中找到了 index.html 文件: / MVC / SRC /主/ web应用/ index.html中

所以我的疑问是: webap 文件夹是一个可以包含我的视图的文件夹(webapp的其他jsp视图进入此文件夹的某个子目录)所以如果我放在这里< strong> index.html 文件默认情况下在Web应用程序启动时打开,我不需要指定欢迎文件或类似的东西吗?

TNX

2 个答案:

答案 0 :(得分:1)

欢迎文件机制在servlet specifications中指定(servlet 3.0版本的10.10节)。它与Spring没什么关系。

对于Tomcat,如果您没有在webapp的描述符中指定任何欢迎文件,则使用默认配置(存在于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个文件用作欢迎文件。

答案 1 :(得分:0)

在您的web.xml文件中有一个名为:

的条目
<welcome-file-list>
   <welcome-file>index</welcome-file>
</welcome-file-list>

你可以定义自己的起点。