Resource interpreted as Stylesheet but transferred with MIME type text/html: css失效
- 异常信息:
Resource interpreted as Stylesheet but transferred with MIME type text/html:
- 可能原因
过滤器或者某个地方对所有的资源请求全部转为了text/html
- 检查方式
利用浏览器查看请求头和响应头

- 主要检查请求头和响应头的content type
样式表应是text/css,并且向服务器发送请求和之后服务器对客户端的响应都应该是text/css;
我个人在项目中遇到的问题就是利用过滤器对所有请求进行编码统一时,将css文件也进行了处理
修改之前的过滤器代码为
System.out.println("**********AllFilter开始工作*********");
HttpServletRequest request=(HttpServletRequest)req;
HttpServletResponse response=(HttpServletResponse)res;
response.setCharacterEncoding("text/html; charset=UTF-8");
- 处理方法
应该对请求进行分类,当为一些css等一类文件就以原来的方式请求进行,不做处理,其它的请求再作处理,修改后代码如下:
System.out.println("**********AllFilter开始工作*********");
HttpServletRequest request=(HttpServletRequest)req;
HttpServletResponse response=(HttpServletResponse)res;
String url=request.getRequestURI();
System.out.println("url:" +url);
if(url.indexOf(".css")>0||url.indexOf(".js")>0||url.indexOf(".png")>0) {
chain.doFilter(request, response);
return;
}
response.setContentType("text/html;text/html; charset=UTF-8");
Resource interpreted as Stylesheet but transferred with MIME type text/html: css失效的更多相关文章
- Resource interpreted as Stylesheet but transferred with MIME type text/plain
今天碰到了Resource interpreted as Stylesheet but transferred with MIME type text/plain 这个错误. 原因:在web中配置了f ...
- 样式加载不出来,浏览器控制台报错:Resource interpreted as Stylesheet but transferred with MIME type text/html
写登录的时候出现的问题,样式时好时坏,浏览器控制台看到的信息是: Uncaught SyntaxError: Unexpected token <Resource interpreted as ...
- css不起作用报错:Resource interpreted as Stylesheet but transferred with MIME type text/html
解决:https://blog.csdn.net/sky_cui/article/details/86703706 找了好久........
- odoo 错误 Resource interpreted as Stylesheet but transferred with MIME type application/x-css:
odoo8 页面内容显示一半, web 控制台显示错误 Resource interpreted as Stylesheet but transferred with MIME type ap ...
- Django 导入css文件,样式不起作用。Resource interpreted as Stylesheet but transferred with MIME type application/x-css
笔者今天在模板中加载css文件时,发现 css样式能够下载再来却无法起作用,而且,图片.js都能够正常使用. 并且 浏览器提示: Resource interpreted as Stylesheet ...
- Resource interpreted as Script but transferred with MIME type text/plain:
我用script做ajax跨域,请求返回的是个文本字符串,chrome提示:Resource interpreted as Script but transferred with MIME type ...
- Chrome 报 Resource interpreted as Script but transferred with MIME type text/plain 警告的解决办法
http://www.2cto.com/os/201312/262437.html 安装了VS2012之后,chrome在加载页面的时候会报 Resource interpreted as Scrip ...
- Resource interpreted as Stylesheet but transferred with MIME || DevTools failed to parse SourceMap:
最近在学SpringBoot,在整合Thymeleaf的时候,配置拦截器.教学上讲SpringBoot已经做好了静态资源映射,所以不需要特地去做排除拦截 以下代码就是我在做登录拦截的时候配置的拦截. ...
- Chrome: Resource interpreted as Font but transferred with MIME type font/x-woff
最近,项目中加入了Bootstrap进行界面优化,但是,项目加载运行之后,控制台总是提示以下错误信息: GET http://localhost:8080/.../fonts/fontawesome- ...
随机推荐
- 吴裕雄--天生自然 HADOOP大数据分布式处理:主机与服务器时间同步设置
- NI Vision 介绍
NI Vision主要包括三种主要软件包: 主程序包(Vision Acquisition Software), 视觉开发模块(Vision Development Module), 以及用于自动检测 ...
- 机器人可以拥有社交智能吗?——微软雷德蒙研究院院长Eric Horvitz与他的个人虚拟助理之梦
Horvitz与他的个人虚拟助理之梦" title="机器人可以拥有社交智能吗?--微软雷德蒙研究院院长Eric Horvitz与他的个人虚拟助理之梦">编者按:到 ...
- AngularJS中格式化日期为指定格式字符串
var date = $filter('date')(new Date(),'MM/dd/yyyy');
- 跨越真实和虚拟世界的边界——走近SIGGRAPH 2014大会
2014大会" title="跨越真实和虚拟世界的边界--走近SIGGRAPH 2014大会"> 作者:孙鑫 微软亚洲研究院研究员 一场大会振奋一座城 温哥华位于加 ...
- 用磁盘工具刻录MACOSX系统启动盘方法
些系统盘用Toast 刻录后无法引导,建议使用磁盘工具刻录系统盘 老手可能早知道这了,仅供新手参考 在应用程序-->实用工具里找到磁盘工具,打开. 将DMG文件拖放到磁盘工具窗口,双击DMG文件 ...
- docker pull很慢解决办法
经常拉取镜像的时候很慢或者拉不下来,这里可以使用阿里云镜像加速器,然后试试看有没有效果. ##使用阿里云镜像加速器 [root@localhost ~]# mkdir -p /etc/docker [ ...
- tfjs-node初体验:训练模型的存储
JS,一门从浏览器兴起,却不止于浏览器的脚本,个人一直认为其是最有潜力的脚本语言.不只是因为ES6优雅的语法,更重要的是其易上手,跨平台的优点. Node将JS从browser带去了client是革命 ...
- Spring返回jsp页面
1.SpringMVC返回的jsp,需要配置相应的viewResolvers,如: <property name="viewResolvers"> <list&g ...
- Java 内部类(成员内部类、局部内部类、静态内部类,匿名内部类)
一.什么是内部类? 内部类是指在一个外部类的内部再定义一个类.内部类作为外部类的一个成员,并且依附于外部类而存在的.内部类可为静态,可用protected和private修饰(而外部类只能使用publ ...