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- ...
 
随机推荐
- Rearrangement
			
In a two dimensional array of integers of size 2×n2 \times n2×n, is it possible to rearrange integer ...
 - Select(快速选择顺序统计量)原理及C++代码实现
			
SELECT算法利用快排中的partition思想来进行无序数组的快速选择. 寻找第i个顺序统计量可以简单理解为寻找第i小的元素. 该算法通过为partition选择一个好的主元,来保证Partiti ...
 - python数据类型:列表List和Set
			
python数据类型:列表List, Set集合 序列是Python中最基本的数据结构 序列中每个元素都分配一个数字,表示索引 列表的数据项不需要具有相同的类型 列表中的值可以重复并且有 ...
 - Linux quota磁盘配额
			
quota:磁盘配额 限制某一群组所能使用的最大磁盘配额 限制某一用户的最大磁盘配额 使用限制: 仅能针对整个filesystem 核心必须支持quota quota的记录文件 只对一般身份使用者有效 ...
 - 【Java集合】试读ArrayList源码
			
ArrayList简介 ArrayList 是一个数组队列,相当于 动态数组.与Java中的数组相比,它的容量能动态增长.它继承于AbstractList,实现了List, RandomAccess, ...
 - vue项目中net::ERR_CONNECTION_TIMED_OUT错误
			
我出错的原因时network地址与我本机ip地址不一致 Network: http://192.168.13.30:8080/ 处理方法: 在vue项目中新建一个vue.config.js文件 配置上 ...
 - 数据库连接中断-spring-springBoot
			
问题:据库和应用在同一台机,数据库用mysql5.6.20,已经升级druid到最新的1.0.7版本,访问的是localhost的mysql,放一个晚上不访问,第二天访问就报错了,重启服务正常,错误提 ...
 - haproxy笔记之一:Haproxy基本安装配置(反向代理,类似Nginx,可以代理tcp的连接,不只是http)(注意iptables和selinux的问题)
			
1.安装haproxy yum -y install haproxy 2.配置文件 # this config needs haproxy- or haproxy- global log 127.0. ...
 - mysql--sql_mode报错整理
			
1.在5.7版本以上mysql中使用group by语句进行分组时, 如果select的字段 , 不是完全对应的group by后面的字段 , 有其他字段 , 那么就会报这个错误 ERROR 1055 ...
 - leetCode-nSum
			
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = tar ...