SpringMVC默认拦截静态资源解决

在这里插入图片描述
No mapping found for HTTP request with URI[/ResponseBodyTest/js/jquery-1.11.0.min.js] in DispathcherServlet with name’springmvc
在这里插入图片描述
查看静态资源路径:发现请求路径并没有写错,出错的原因是什么呢?在这里插入图片描述
在这里插入图片描述
原因:核心控制器拦截的路径是/,/表示“http://localhost:8080/项目名/”这个路径,所以
如下路径都可以被拦截:
http://localhost:8080/HelloMVC/js/jquery.js
http://localhost:8080/HelloMVC/a
在这里插入图片描述
如何解决:

  • 修改tomcat的配置文件
    在这里插入图片描述
  • 在spring中配置
    方法1:(推荐)
      在这里插入图片描述
    方法2:location=”/”表示请求根目录下的所有内容
    <mvc:resources location="/,classpath:/META-INF/publicResources/" mapping="/js/**"/>

No mapping found for HTTP request with URI[/ResponseBodyTest/js/jquery-1.11.0.min.js] in DispathcherServlet with name’springmvc解决方案就是这些

猜你喜欢

转载自blog.csdn.net/weixin_44142296/article/details/85723554