用ssm+layui在写页面的时候,发现无法找到资源路径

<script src="js/layui/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/js/layui/layui.js" charset="utf-8"></script>

备注在html中是无法识别的${},jsp才可以,所以html你可以看一下路径然后写死。

clean项目

这是一个maven项目
解决GET http://localhost:8080/js/layui/layui.js net::ERR_ABORTED 404

添加静态资源映射

在spring-mvc中添加静态资源映射

<!--静态资源映射-->
    <mvc:resources mapping="/js/**" location="/WEB-INF/js/"/>
<script src="/WEB-INF/js/layui/layui.js" charset="utf-8"></script>

直接上面这样写是不可以的

重启Tomcat

参考链接

解决:GET http://localhost:8080/static/js/jquery.min.js net::ERR_ABORTED 404

相关文章:

  • 2021-06-06
  • 2021-07-18
  • 2022-12-23
  • 2021-11-16
  • 2021-10-18
  • 2022-02-08
  • 2021-10-21
猜你喜欢
  • 2022-12-23
  • 2021-11-13
  • 2021-12-28
  • 2022-01-12
  • 2021-11-29
  • 2021-08-10
  • 2021-12-29
相关资源
相似解决方案