首页 > 编程语言 > 详细

SpringMVC随笔记录

时间:2017-08-30 15:23:09      阅读:267      评论:0      收藏:0      [点我收藏+]

在web.xml里可以配置webapp的默认首页,格式如下:

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

这里要注意,如果首页是放在webapp根目录下的index.jsp则不用配置<welcome-file>默认通过http://ip:port/webapp/访问的就是index.jsp文件,

但是如果是index.html是主页则首先要在springmvc.xml里配置

<mvc:resources mapping="/index.html" location="/index.html"/>

因为.html是静态文件会被springMVC拦截,之后还要在web.xml里配置为上面的<welcome-file>..,且index.html前面不能有/,否则

只能通过http://ip:port/webapp/index.html访问index.html页面(不过第一次由IDE弹出的页面这种http://ip:port/webapp/形式可以显示index.html,但是刷新后就没了),

而不能通过http://ip:port/webapp/访问index.html页面,即下面的配置某种意义上说是错误的(不过我觉得这该叫bug吧)

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

SpringMVC随笔记录

原文:http://www.cnblogs.com/silentdoer/p/7452920.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!