• 异常信息:

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失效的更多相关文章

  1. Resource interpreted as Stylesheet but transferred with MIME type text/plain

    今天碰到了Resource interpreted as Stylesheet but transferred with MIME type text/plain 这个错误. 原因:在web中配置了f ...

  2. 样式加载不出来,浏览器控制台报错:Resource interpreted as Stylesheet but transferred with MIME type text/html

    写登录的时候出现的问题,样式时好时坏,浏览器控制台看到的信息是: Uncaught SyntaxError: Unexpected token <Resource interpreted as ...

  3. css不起作用报错:Resource interpreted as Stylesheet but transferred with MIME type text/html

    解决:https://blog.csdn.net/sky_cui/article/details/86703706 找了好久........

  4. 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 ...

  5. Django 导入css文件,样式不起作用。Resource interpreted as Stylesheet but transferred with MIME type application/x-css

    笔者今天在模板中加载css文件时,发现 css样式能够下载再来却无法起作用,而且,图片.js都能够正常使用. 并且 浏览器提示: Resource interpreted as Stylesheet ...

  6. Resource interpreted as Script but transferred with MIME type text/plain:

    我用script做ajax跨域,请求返回的是个文本字符串,chrome提示:Resource interpreted as Script but transferred with MIME type ...

  7. 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 ...

  8. Resource interpreted as Stylesheet but transferred with MIME || DevTools failed to parse SourceMap:

    最近在学SpringBoot,在整合Thymeleaf的时候,配置拦截器.教学上讲SpringBoot已经做好了静态资源映射,所以不需要特地去做排除拦截 以下代码就是我在做登录拦截的时候配置的拦截. ...

  9. Chrome: Resource interpreted as Font but transferred with MIME type font/x-woff

    最近,项目中加入了Bootstrap进行界面优化,但是,项目加载运行之后,控制台总是提示以下错误信息: GET http://localhost:8080/.../fonts/fontawesome- ...

随机推荐

  1. Linux修改主机名称方法

    碰到这个问题的时候,是在安装Zookeeper集群的时候,碰到如下问题 java.net.UnknownHostException: XXXX Name or service not knownjav ...

  2. [LC] 434. Number of Segments in a String

    Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...

  3. 58)PHP,后台登录步骤示意图

    注意上面的action提交位置: 并且注意下面的两个东西:

  4. 吴裕雄--天生自然 Hadoop大数据分布式处理:关闭CenterOS 7防火墙

    使用命令:systemctl status firewalld.service 查看防火墙状态 执行后可以看到绿色字样标注的“active(running)”,说明防火墙是开启状态 使用命令:syst ...

  5. 作业:for循环,迭代法和穷举法

                                                    for()循环 四要素:初始条件,循环条件,状态改变,循环体. 执行过程:初始条件--循环条件--循环体 ...

  6. Oracle中实现sql查询得到连续号码段

    一.表名为t的表中数据如下: select * from t; FPHM KSHM ---------- ---------- 实现代码如下: select b.fphm,min(b.kshm),ma ...

  7. django框架进阶-form组件-长期维护

    ##################     form组件做了什么事情?      ####################### 之前web开发的模式,以注册为例 1,要有一个注册页面,然后有一个f ...

  8. 遍历一个文件夹,打印出该文件夹下所有的py文件

    import os def iterbrowse(path): for home, dirs, files in os.walk(path): for filename in files: yield ...

  9. struts 2.1.8.1的sx:datetimepicker标签出现NaN错误的原因和解决办法

     作者:Junsan.Jin 邮箱:junsanjin@gmail.com QQ:1305896503 本文原始地址:http://www.rsky.com.cn/Article/java/201 ...

  10. UFT安装目录简单介绍

    1.在安装的help目录下可查看UFT相关的文档 2.在samples/filght/app目录下可看到UFT自带的用作测试的软件