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

以下代码就是我在做登录拦截的时候配置的拦截。

@Override
public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LoginHandleInterceptor()).addPathPatterns("/**")
.excludePathPatterns("/","/index.html","/user/login");
} 一开始,资源都能映射,一切感觉都OK,上午搞定后吃个饭,下午继续搞的时候,发现有的样式突然失效了。
在谷歌浏览器检查问题的时候,发现了这句话,
DevTools failed to parse SourceMap: -------------------------------------------------------------------------------------------
普遍解释是
在现在写网站的时候,如果有很多的javascript文件,拿ASP.NET NVC来说,
在渲染内容到客户端浏览器的时候,如果你使用一些Bundle类的话,能够合并并且压缩那些js文件,
并且去除其中的空格等元素,从而减小文件的容量,提高网页的反应速度
但是这样一样造成的问题就是在浏览器端无法对js文件进行调试,因为进过压缩的文件很紧凑,没有空格与换行。
概括来讲,SourceMap就是如何把压缩后的js代码映射成格式化代码的方法。
当你在Production环境部署代码的时候,伴随着压缩与优化话的js代码
还要有一个包含原始js代码的sourcemap文件。当客户端浏览器Chrome在收到这个压缩后的js文件后,
它会自动的去寻找服务器上相关的sourcmap文件并把压缩的js代码转换成格式规范的js代码。 以上摘抄与https://blog.csdn.net/sundacheng1989/article/details/51118865
----------------------------------------------------------------------------------
总之所有的解决办法大概都是这幅图

但是我在关掉开发者工具额这两个选项后,出现了另一个报错

Resource interpreted as Stylesheet but transferred with MIME

这个错误百度了一下,各种解决办法。头都大了。然后在恼火中一直点击
Resource interpreted as Stylesheet but transferred with MIME后面的地址链接,一直被我的拦截器拦住跳回登录
页的时候。在想是不是拦截器的问题。注释了一下,发现就是这逼在搞鬼。我也不知道SpringBoot到底有没有对静态资源自动映射。
总之我把拦截的代码加上了红字的代码就OK了。
@Override
public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LoginHandleInterceptor()).addPathPatterns("/**")
.excludePathPatterns("/","/index.html","/user/login","asserts/**","webjars/**");
}
以上是我的解决方法
 


Resource interpreted as Stylesheet but transferred with MIME || DevTools failed to parse SourceMap:的更多相关文章

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

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

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

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

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

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

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

  5. Resource interpreted as Stylesheet but transferred with MIME type text/html: css失效

    异常信息: Resource interpreted as Stylesheet but transferred with MIME type text/html: 可能原因 过滤器或者某个地方对所有 ...

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

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

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

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

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

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

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

随机推荐

  1. freemarker技术入门例子(结合struts2)

    由于最近项目里面要求要使用freemarker技术来做展现层,所以在网上搜索了好多资料,基础知识是看了李刚原来写的那本<struts2权威指南>.一直想在网上找一个很基础的例子来入门,但是 ...

  2. python编写的banner获取代码的两种方式

    1.无选项和帮助信息 #!/usr/bin/env python #coding:utf-8 import socket import sys import os from threading imp ...

  3. GoJS实例2

    复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果 <!DOCTYPE html> <html> <head> <meta name=&quo ...

  4. Metasploit学习笔记——客户端渗透攻击

    1.浏览器渗透攻击实例——MS11-050安全漏洞 示例代码如下 msf > use windows/browser/ms11_050_mshtml_cobjectelement msf exp ...

  5. List<string>绑定到DataGridView控件

    问题 将一个简单的List<string>作为数据源绑定到 DataGridView myDataGridView.DataSource = myStringList; 但是只得到一个名为 ...

  6. linux安装postgresql数据库

    本文提供数据库安装脚本,有部分需要优化,就是脚本中的方法执行存在前后依赖,但是代码里面没有对上一个执行结果进行判断,如果提供的路径和安装包没有问题,脚本能够正常执行 #!/bin/bash # ins ...

  7. 十七、React路由嵌套:头部导航+侧边导航

    一.概述 实现功能:点首页,展示首页,同时在左侧有个首页的各个栏目导航:点用户,同首页: 二.代码实现 1. src/App.js import React from 'react'; import ...

  8. 访问eureka 显示xml

    两种解决方式: 方式一:(我是通过此方式解决的) 一个博客“http://blog.csdn.net/l5764773160/article/details/77483730”,他的解决方案是: 将项 ...

  9. 基于Ambari的WebUI实现服务缩容

    基于Ambari的WebUI实现服务缩容 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.实现服务的扩容 1>.进入到主机的管理界面 2>.查看主机的信息概览 3&g ...

  10. Oracle-SQL 小题

    1.查询姓名中不包含C和c的员工信息 ; ①字符函数 instr(input,char,m,n) 的用法:返回在字符值中查找字符串char的数字位置.参数m作为查找的开始,参数n代表第n次发现.m和n ...