javaweb默认主页

 1.默认tomcat容器的默认页面。
<welcome-file-list> 
  <welcome-file>/index.html</welcome-file> 
</welcome-file-list>

 

这种方式适合访问静态的页面(也包括JSP)或者说是没有任何参数的页面。

2.spirng mvc 默认index controller 方式
如果在tomcat容器没有配置默认页面,怎spring mvc 会主动去寻找/index的controller,如果有则会调用,没有则会显示404页面。
@RequestMapping(value="/index")
public ModelAndView index(HttpServletRequest request, HttpServletResponse response){
return new ModelAndView("index");
}

3.spirng mvc 配置根节点访问“/”方式
这种方法比较极端,就是配置一个名为“/”的controller,就是输入完网址之后就会调用。这种方法是前面两种方法都没有配置的时候。
@RequestMapping(value="/") 
public ModelAndView index(HttpServletRequest request, HttpServletResponse response){
  return new ModelAndView("index");
}

 


posted @ 2016-07-26 10:32  德德豸  阅读(159)  评论(0编辑  收藏  举报