静态资源路径问题
- 特别是将静态资源放在静态文件夹下,特别注意,如:

- Sping-mvc配置文件进行放行
<!--放行静态资源-->
<mvc:default-servlet-handler/>
<!--<mvc:resources location="/static/css/" mapping="/css/**" />-->
<!--<mvc:resources location="/static/images/" mapping="/images/**" />-->
<!--<mvc:resources location="/static/js/" mapping="/js/**" />-->
<link rel="shortcut icon" href="${pageContext.request.contextPath}/static/images/logo.png">
../ 上一级目录
/ URL根路径,http://localhost:8080/web/js/jquery.js的http://localhost:8080/
./ web工程根路径,http://localhost:8080/web/
在maven Spring MVC中使用jquery
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.1.1</version>
</dependency>
<script src="/webjars/jquery/3.1.1/jquery.min.js"></script>
<mvc:resources location="/webjars/" mapping="/webjars/**" />
使用layui
<link rel="stylesheet" href="layui/css/layui.css">
<script src="layui/layui.js"></script>
- Spring MVC中配置过滤器(springmvc.xml)
<mvc:resources location="/layui/" mapping="/layui/**" />
在Spring MVC中访问html
- 默认拦截静态资源,包括html文件
- 配置过滤器(springmvc.xml)
<mvc:resources location="/" mapping="/*.html"/>