當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
使用SpringBoot框架和SpringSecurity框架整合出现because its MIME type ('text/html') is not executable
生活随笔
收集整理的這篇文章主要介紹了
使用SpringBoot框架和SpringSecurity框架整合出现because its MIME type ('text/html') is not executable
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前端頁面出現:
Refused to execute script from ‘http://localhost:8080/login’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled.
解決方法:
所以要找到對自定義的springSecurity安全框架的配置類進行修改
自定義的springSecurity安全框架的配置類,繼承WebSecurityConfigurerAdapter,重寫其中的方法configure
我們可以在authorizeRequests() 后定義多個antMatchers()配置器來控制不同的url接受不同權限的用戶訪問。
antMatchers在這里配置哪些頁面或資源不需要認證:
Refused to execute script from ‘http://localhost:8080/login’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled.
可對頁面中的引用路徑進行修改,有可能是頁面中的資源路徑沒有引用到static下的靜態資源。
例如:
在這個相對路徑中,我的images文件夾在default下
由于前面少加一個文件夾的路徑,就會導致Spring Security框架攔截了該資源的請求,
所以在前面加上default
問題就解決了
注意:該報錯不會具體指出是哪一行出現錯誤,所以要細心檢查前端引用資源的代碼,也有可能是圖片,js, css, 字體文件,音頻,視頻沒有引用到static下的靜態資源。
static 目錄存放我們的web靜態資源頁面
templates 存放我們的html, jsp, ftl等各種格式網站頁面
總結
以上是生活随笔為你收集整理的使用SpringBoot框架和SpringSecurity框架整合出现because its MIME type ('text/html') is not executable的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用Lombok优化代码
- 下一篇: SpringBoot和SpringSec