项目结构:

前端踩坑Resource interpreted as Stylesheet but transferred with MIME type text/html

问题描述:

1,跑在本地tomcat上时,用IE,FireFox,Chrome访问都没问题,CSS能加载且有效果

2,打包到云端Tomcat时,用IE访问正常,用FireFox和Chrome访问时能加载CSS文件,但是没有效果,报错如下:Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://(ip)/JavaWeb_war/css/home.css"

解决方法:

1,删去了html头部的声明<!DOCTYPE html>(https://blog.csdn.net/lamanchas/article/details/77647521),虽然暂时能解决问题,但是不是最好的方法。

2,通过排查发现应该统一客户端请求时Accept和返回时的Content-Type,一般Tomcat自动完成配置(在tomcat/conf/web.xml中),但是我工程中加了过滤器,统一了返回的类型为text/html,改了就行了

前端踩坑Resource interpreted as Stylesheet but transferred with MIME type text/html前端踩坑Resource interpreted as Stylesheet but transferred with MIME type text/html前端踩坑Resource interpreted as Stylesheet but transferred with MIME type text/html


 

相关文章:

  • 2021-09-05
  • 2021-09-20
  • 2022-12-23
  • 2021-12-28
  • 2021-05-03
猜你喜欢
  • 2021-10-17
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2021-10-27
相关资源
相似解决方案