今天在是用公司的報表插件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