码迷,mamicode.com
首页 > 编程语言 > 详细

SpringMVC随笔记录

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

标签:笔记   bug   resources   source   静态文件   color   mvc   web.xml   oca   

在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随笔记录

标签:笔记   bug   resources   source   静态文件   color   mvc   web.xml   oca   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!