• 异常信息:

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. DataGrip设置时区

    新版本DataGrip以默认时区取世界标准时间.要想时间显示正常,需要将时区变为上海时区,可手动在连接配置里设置参数.如下图: 操作步骤1.右键打开你想要修改的数据库连接的Properties菜单:2 ...

  2. ROS中的日志(log)消息

    学会使用日志(log)系统,做ROS大型项目的主治医生 通过显示进程的运行状态是好的习惯,但需要确定这样做不会影响到软件的运行效率和输出的清晰度.ROS 日志 (log) 系统的功能就是让进程生成一些 ...

  3. 快速进入当前目录的cmd窗口

  4. 荼菜的iOS笔记--UIView的几个Block动画

    前言:我的第一篇文章荼菜的iOS笔记–Core Animation 核心动画算是比较详细讲了核心动画的用法,但是如你上篇看到的,有时我们只是想实现一些很小的动画,这时再用coreAnimation就会 ...

  5. Ubuntu gnome安装Monaco字体,FontForge module is probably not installed

    首先下载原始Monaco字体,注意我只找到了这一款在ubuntu的gnome下可见,其他的各种monaco即使安装了也看不到. https://gist.github.com/epegzz/16342 ...

  6. MyBatisUtil

    package com.it.util; import java.io.IOException; import java.io.Reader; import org.apache.ibatis.io. ...

  7. js 实现排序算法 -- 插入排序(Insertion Sort)

    原文: 十大经典排序算法(动图演示) 插入排序 插入排序(Insertion-Sort)的算法描述是一种简单直观的排序算法.它的工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描, ...

  8. JAVA 获取网页源代码保存到本地文件

    package httpget; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundExce ...

  9. MatterTrack Route Of Network Traffic :: Matter

    Python 1.1 基础 while语句 字符串边缘填充 列出文件夹中的指定文件类型 All Combinations For A List Of Objects Apply Operations ...

  10. SpringMVC之参数绑定

    1.Controller package com.tz.controller; import org.springframework.beans.factory.annotation.Required ...