我有这个问题。Chrome继续返回此错误
资源解释为样式表,但以MIME类型text/html传输
受此错误影响的文件只有Style、chosen和jquery-gentleselect(以相同方式导入索引的其他CSS文件工作良好且没有错误)。我已经检查了我的MIME类型和文本/css已经在css上。
老实说,我想从理解问题开始(这似乎是我一个人做不到的事情)。
我有这个问题。Chrome继续返回此错误
资源解释为样式表,但以MIME类型text/html传输
受此错误影响的文件只有Style、chosen和jquery-gentleselect(以相同方式导入索引的其他CSS文件工作良好且没有错误)。我已经检查了我的MIME类型和文本/css已经在css上。
老实说,我想从理解问题开始(这似乎是我一个人做不到的事情)。
当前回答
使用角?
这是一个需要记住的非常重要的警告。
基本标签不仅要在头部,而且要在正确的位置。
我有我的基础标签在错误的地方在头部,它应该来之前任何标签与url请求。基本上把它作为标题下面的第二个标签为我解决了这个问题。
<base href="/">
我在这里写了一篇小文章
其他回答
如果您使用的是JSP,则此问题可能来自您的servlet映射。 如果你的映射默认使用url,就像这样:
@WebServlet("/")
然后容器解释CSS url,并转到servlet,而不是转到CSS文件。
我有同样的问题,我改变了我的映射,现在一切正常
我有同样的问题,几分钟后,我破译,我错过了添加文件扩展名到我的头。所以我改了下面这行:
<link uic-remove rel="stylesheet" href="css/bahblahblah">
to
<link uic-remove rel="stylesheet" href="css/bahblahblah.css">
使用角
在我的情况下,使用ng-href而不是href解决了这个问题。
注意:
我和laravel一起做后台
有同样的错误,因为我忘记发送一个正确的头
header("Content-type: text/css; charset: UTF-8");
print 'body { text-align: justify; font-size: 2em; }';
In my case, same error was coming with JSP. This is how I got to the root of this issue: I went to the Network tab and clearly saw that the browser request to fetch the css was returning response header having "Content-type" : "text/html". I opened another tab and manually hit the request to fetch the css. It ended up returning a html log in form. Turns out that my web application had a url mapping for path = / Tomcat servlet entry : (@WebServlet({ "/, /index", }). So, any unmatching request URLs were somehow being matched to / and the corresponding servlet was returning a Log in html form. I fixed it by removing the mapping to /
此外,tomcat配置wrt处理css MIME-TYPE已经存在。