1. Default page for the default Tomcat container.
/index.html
This is a good way to access static pages (including JSPs) or pages that don't have any parameters.
2.SPIRNG MVC Default Index Controller mode
If the Tomcat container does not have a default page configured, how spring MVC will proactively look for/index controllers, if any, will be called, and no 404 pages will be displayed.
@RequestMapping (value= "/index")
Public Modelandview Index (httpservletrequest request, httpservletresponse response) {
return new Modelandview ("index");
}
3.SPIRNG MVC Configuration root node Access "/" mode
This approach is extreme, is to configure a controller named "/", that is, after entering the URL will be called. This method is not configured for the previous two methods.
@RequestMapping (value= "/") public Modelandview Index (httpservletrequest request, httpservletresponse response) { return new Modelandview ("index"); }
The level of the three methods:1>>3>>2; because Tomcat has a higher container level than spring, and the above 3-clock configuration is the case, use Tomcat preferentially. Because the controller is configured with a "/", it is matched to the relevant controller instead of looking for the/index controller first.
Note that even if Web. XML is not added, Tomcat will automatically default to find the index file under the Webroot directory, and if you want to use the next two methods, make sure that there are no index-related files under Webroot.
If the above method is wrong, please point out that only for learning
3 ways to set default access pages under Spring MVC