只说一种我自己用的方法:
在web.xml中配置了拦截所有路径之后,再在springmvc中使用
mvc:resources标签
记住不能和mvc:default-servlet-handler标签一起用
且需要开启<mvc:annotation-driven />注解
<mvc:resources location="/WEB-INF/ui/js/“ mapping="js/**" />
<mvc:resources location="/WEB-INF/ui/css/" mapping="css/**" />
<mvc:resources location="/WEB-INF/ui/images/" mapping="images/**" />
<mvc:resources location="/WEB-INF/ui/scripts/" mapping="scripts/**" />
<mvc:resources location="/" mapping="**.html" />
location是资源在webapp下的绝对路径,mapping是在html中写的路径
第一行的意思是:html中写 src=“js/xxxx.js”,就会去/WEB-INF/ui/js文件夹下查找