简体   繁体   English

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

[英]How is it specified what is the first page to show in this Spring MVC demo application?

I am studtyin for the Spring Core certification and I have a doubt related Spring MVC use. 我是Spring Core认证的学习者,对Spring MVC的使用有疑问。

I have a demo webapp. 我有一个演示webapp。 When I run it on TomCat server it is automatically open this URL into the browser: 当我在TomCat服务器上运行它时,它会自动在浏览器中打开以下URL:

http://localhost:8080/mvc/

that show a web page. 显示网页。

Reading on the course slides it say that: 在课程幻灯片上阅读时会说:

Once deployed, navigate to the index page at http://localhost:8080/mvc . 部署后,浏览至http:// localhost:8080 / mvc的索引页面。 You should see the index page display 您应该会看到索引页面显示

Ok, I can't find no information about a main page that have to be open as entry point of my webapp but I find the index.html file into the folder: /mvc/src/main/webapp/index.html 好的,我找不到关于必须作为我的Web应用程序入口打开的主页的信息,但是我在文件夹中找到了index.html文件: /mvc/src/main/webapp/index.html

So my doubt is: the webap folder is a folder that could contains my views (the other jsp views of the webapp are into some subdirectory into this folder) and so if I put here an index.html file it is open by default at the startup of the web application without that I need to specify a welcome file or something like this? 因此,我的疑问是: webap文件夹是一个可能包含我的视图的文件夹(该Webapp的其他jsp视图位于该文件夹的某个子目录中),因此,如果我将index.html文件放在此处,则默认情况下该文件处于打开状态没有该Web应用程序启动,我需要指定一个欢迎文件或类似的东西?

Tnx TNX

The welcome file mechanism is specified in the servlet specifications (section 10.10 of the servlet 3.0 version). Servlet规范 (Servlet 3.0版本的10.10节)中指定了欢迎文件机制。 It doesn't have much to do with Spring. 它与Spring无关。

In the case of Tomcat, if you don't specify any welcome file in your webapp's descriptor, the default configuration (present in tomcat's conf/web.xml file) is used instead. 对于Tomcat,如果您未在Web应用程序的描述符中指定任何欢迎文件,则将使用默认配置(在tomcat的conf / web.xml文件中提供)。 And it contains 它包含

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

which means that Tomcat will use these 3 files as welcome file. 这意味着Tomcat将使用这3个文件作为欢迎文件。

in your web.xml file there is an entry named : 在您的web.xml文件中,有一个名为的条目:

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

there you can define your own starting point. 在那里您可以定义自己的起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM