解决springboot中引入不了js,css和图片等问题

140 阅读1分钟

会报错hello:10 GET http://localhost:8080/static/layui/layui.js net::ERR_ABORTED 404
提示***找不到
在这里插入图片描述

是因为在application中没有定义
可以在application.properties中写也可以自己定义一个application.yml写

#设定静态文件路径包括js,css等(springboot默认的静态资源文件是在static目录下,也可以自定义添加路径)
spring.mvc.static-path-pattern=/static/**

1.application.properties里面
在这里插入图片描述
2.application.yml里面
在这里插入图片描述