springMVC 中静态资源的引用
关于静态资源的引用上。springmvc-servlet.xml的配置为:
<!-- 配置js,css等静态文件直接映射到对应的文件夹,不被DispatcherServlet处理 -->
<mvc:resources location="/WEB-INF/resources/**" mapping="/resources/**"/>
相关位置图如下:
在MyHome.jsp中引用:
<link rel="stylesheet" href="./resources/css/3col_leftNav.css" type="text/css">
引用的css不起作用。
后台提示:
No mapping found for HTTP request with URI [/SpringMVCTest/user/resources/css/3col_leftNav.css] in DispatcherServlet with name 'spring-mvc'
No mapping found for HTTP request with URI [/SpringMVCTest/user/] in DispatcherServlet with name 'spring-mvc'
------解决方案--------------------路径应用错了, 可以改成
<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/css/3col_leftNav.css" type="text/css">