1. 程式人生 > >its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

  今天遇到的問題,使用SpringBoot 的時候,加上 SpringSecurity 之後,頁面的請求總是會報錯its MIME type ('text/html') is not executable, and strict MIME type checking is enabled

Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/jquery/dist/jquery.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/bootstrap/dist/js/bootstrap.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/bootstrap-hover-dropdown/bootstrap-hover-dropdown.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/angular/angular.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/angular-messages/angular-messages.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/angular-ui-router/release/angular-ui-router.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/angular-bootstrap/ui-bootstrap.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/angular-local-storage/dist/angular-local-storage.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/angular-animate/angular-animate.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/bootstrap-timepicker/js/bootstrap-timepicker.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/angular-translate/angular-translate.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/angular-translate-storage-cookie/angular-translate-storage-cookie.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/static/style/bootstrap-modal/js/bootstrap-modal.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/static/style/bootstrap-modal/js/bootstrap-modalmanager.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/static/style/bootstrap-hover-dropdown/bootstrap-hover-dropdown.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/bower_components/artDialog/dist/dialog.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/static/scripts/myUtils.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/static/scripts/basePath.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
login#action/login:1 Refused to execute script from 'http://127.0.0.1:8088/knight/web/login/js/loginController.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

但是加上之後呢又不存在這個題,多方查閱,最後,是SpringSecurity攔截掉了,檢查自己的程式碼,最後發現是配置的路徑不對

@Override
public void configure(WebSecurity webSecurity) throws Exception{
    webSecurity
            .ignoring()
            .antMatchers("web/**");//放開所有靜態資源
}

改成:

@Override
public void configure(WebSecurity webSecurity) throws 
Exception{ webSecurity .ignoring() .antMatchers("/web/**");//放開所有靜態資源 }

重啟,就可以了.