對於錯誤“Refused to execute script from '...' because its MIME type ('') is not executable, and strict MIME type checking is enabled.”的處理。


今天在是用公司的報表插件Stimulsoft時發現的問題。之前可以正常使用,突然不能加載了。查看發現得到這個錯誤。

查看請求頭

可以看到,請求正常響應,但是發現 Content-Type是空的,但是引入了X-Content-Type-Options。

X-Content-Type-Options 響應首部相當於一個提示標志,被服務器用來提示客戶端一定要遵循在 Content-Type 首部中對  MIME 類型 的設定,而不能對其進行修改。這就禁用了客戶端的 MIME 類型嗅探行為,換句話說,也就是意味着網站管理員確定自己的設置沒有問題。 

查詢之后,發現是最近在web.xml中加入了HttpHeaderSecurityFilter導致的。

<filter> <filter-name>httpHeaderSecurity</filter-name> <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class> <async-supported>true</async-supported> </filter> 

那么禁用這個特性,需要修改為

<filter> <filter-name>httpHeaderSecurity</filter-name> <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>blockContentTypeSniffingEnabled</param-name> <param-value>false</param-value> </init-param> </filter> 

 

 

參考鏈接  http://www.jackieathome.net/archives/369.html?utm_source=tuicool&utm_medium=referral

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM