• 异常信息:

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. 如何使用css伪类,实现div左上角出现封面等提示信息

     HTML <div class="ui-cover-tip”><div> CSS .ui-cover-tip{ position: relative; width: ...

  2. Vue创建项目及基本语法 一

    目录 目录: 一.创建Vue项目 0.使用环境要求及说明 1.使用命令创建项目 2.启动项目 二.简单指令 1.变量: 2.动态绑定变量值 3.v-once指令 4.v-html解析html 5.v- ...

  3. android愤怒小鸟游戏、自定义View、掌上餐厅App、OpenGL自定义气泡、抖音电影滤镜效果等源码

    Android精选源码 精练的范围选择器,范围和单位可以自定义 自定义View做的小鸟游戏 android popwindow选择商品规格颜色尺寸效果源码 实现Android带有锯齿背景的优惠样式源码 ...

  4. Learn Git Lesson06 - 分离头指针

    ============== 知识点 分离头指针 HEAD 含义 git diff 分离头指针 (Detached HEAD) 有时候想尝试性修改某些内容(实验),也许并不会真的提交到分支,这时候可以 ...

  5. 蓝桥杯-PREV28-地宫取宝

    先自己用dp解了一遍,然后看了官方讲解视频是用记忆化搜索做的.感觉那位老师的方法比较容易实现(效率上和我的差不多的):记录一下三种方法. 动态规划 地宫取宝 1.195KB C++ 正确 100 15 ...

  6. svn安装使用1(转载)

    SVN服务器搭建和使用(一) Subversion是优秀的版本控制工具,其具体的的优点和详细介绍,这里就不再多说. 首先来下载和搭建SVN服务器. 现在Subversion已经迁移到apache网站上 ...

  7. linux上apache的安装

    1.简介 Apache HTTP Server(简称Apache或httpd)是Apache软件基金会的一个开放源代码的网页服务器软件,旨在为unix,windows等操作系统中提供开源httpd服务 ...

  8. RSA算法原理(简单易懂)

    1. 什么是RSA RSA算法是现今使用最广泛的公钥密码算法,也是号称地球上最安全的加密算法.在了解RSA算法之前,先熟悉下几个术语 根据密钥的使用方法,可以将密码分为对称密码和公钥密码 对称密码:加 ...

  9. [LC] 236. Lowest Common Ancestor of a Binary Tree

    Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...

  10. javaWeb简单登录实现验证数据库

    用户登录案例需求: 1.编写login.html登录页面 username & password 两个输入框 2.使用Druid数据库连接池技术,操作mysql,day14数据库中user表 ...