Spring boot 无法加载css样式,项目报错Could not find the original style sheet.

最近在 给公司做一个系统,使用了springboot框架,同时也遇到了一些大坑

在网上找到了一个好看的模版的,(非前后端的分离)但是无法加载css和image的文件

今天跟大家分享一下我碰到的坑,正常界面是这样的。很美很漂亮吧。

Spring boot 无法加载css样式,项目报错Could not find the original style sheet.

但是没配置完成是这样的,

Spring boot 无法加载css样式,项目报错Could not find the original style sheet.

有没有想砸电脑的冲动呀 宝宝们

现在我告诉大家怎么回事

1.打开浏览器的F12功能 你发现都是css报404

Spring boot 无法加载css样式,项目报错Could not find the original style sheet.

这是为什么呢 ?因为你配置application的时候已经配置请求去找template下的静态资源了 你的css js已经放在static下了所以

Spring boot 无法加载css样式,项目报错Could not find the original style sheet.

2.html页面中的引用一定不要加上static 直接是static下的js/你所引用的.js千万不要加static 以前spring的时候你可以把鼠标放在这里点过去现在不需要。
Spring boot 无法加载css样式,项目报错Could not find the original style sheet.

这是正确的哦

Spring boot 无法加载css样式,项目报错Could not find the original style sheet.
本篇博客解决了我的问题,然后想记录一下,然后转载了另外一篇博主的博客。