Refused to execute script from 'http://localhost:8080/login.html'

这两天学习spring security,碰到了一个坑,我给记录一下.
浏览器控制报错信息
Refused to execute script from ‘http://localhost:8080/login.html’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled.
login.html:18 Uncaught ReferenceError: $ is not defined
at login.html:18
html页面
在这里插入图片描述
由于我把该页面放在public文件夹下而不是templates下,所以这里的thymeleaf模板引擎在访问该页面的时候th:是不起作用的,所以这里引入js路径的是src而不是th:src。访问该页面时组件的点击事件不起作用。控制台报错如下
在这里插入图片描述
在这里我的静态资源路径已经放行
在这里插入图片描述
但是引入JQ仍然是错误的,排查了好久,发现是因为我引入的路径有问题,路径确实被拦截了,因为在spingboot中静态资源默认路径是在static下的所有文件和文件夹。所以我们在写路径时就不需要在写/static/,而我上面写的路径是src="…/static/js/jquery-3.4.1.min.js",这样访问静态资源security会拦截,
因此静态资源引入我们只要学src="/js/jquery-3.4.1.min.js"就可以了

在这里插入图片描述
改完之后访问就没有问题了,事件也起作用了。
在这里插入图片描述