在用springmvc架构开发网站的过程中,离不开开发前台html页面,html经常需要使用本地相关的资源,如:图片,js,css等,一般情况下,我们可以通过使用相对路径的方式来对这些资源进行指向和访问,如:

如上图的代码,可以用浏览器直接打开此处的代码,banner-graphic.png图片也能够正常显示在页面上,但是,在启动服务器时,在浏览器中打开此文件的时候,图片并不会显示。
<bean id="viewResolver" class="org.springframework.web.servlet.view.mustache.MustacheViewResolver">
<property name="cache" value="false" />
<property name="prefix" value="WEB-INF/mustache/" />
<property name="suffix" value=".mustache" />
<property name="templateLoader">
<bean class="org.springframework.web.servlet.view.mustache.MustacheTemplateLoader" />
</property>
<property name="order" value="1" />
</bean>
public Map<String, Object> newModel(HttpServletRequest re) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("contextPath", re.getContextPath());
return map;
}
#head-image{
height:75px;
margin-bottom:0;
background-image:url(../images/banner-graphic.png);
}