昨晚,在做一个自己感兴趣的东西时,发现浏览器报警告,Failed to decode downloaded font以及OTS parsing error: Failed to convert *** font to ***。

但是这个问题从来没有遇到过,在网上找了一会儿答案后,发现了类似的问题回答下有网友猜测是拦截器没通过,所以我检查了shiro的拦截配置:

<property name="filterChainDefinitions">
<value>
/=authc
/index=authc
/logout=logout
/assets/** = anon
/css/** = anon
/fonts/**=anon
/img/**=anon
/**= user
</value>
</property>

但是这个配置理论上是没问题的,所以不是这个问题。

今天在查阅了一些资料后,发现了可能的原因:

在maven的filter解析font文件时,它破坏了font文件的二进制文件格式,导致浏览器解析出错。

解决的思路是:font文件不需要filter,因此我们需要在配置中设置一下(SpringBoot在pom.xml中写入):

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<!-- fonts file cannot use filter as the data structure of byte file will be changed via filter -->
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>static/fonts/**</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>static/fonts/**</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>

在经如上所示的配置后,maven在编译项目时不解析font文件,浏览器就不会报警告,字体也可以正常显示。

浏览器警告Failed to decode downloaded font和OTS parsing error: Failed to convert *** font to ***的更多相关文章

  1. Spring Boot + Bootstrap 出现"Failed to decode downloaded font"和"OTS parsing error: Failed to convert WOFF 2.0 font to SFNT"

    准确来讲,应该是maven项目使用Bootstrap时,出现 "Failed to decode downloaded font"和"OTS parsing error: ...

  2. Spring Boot - Font Awesome OTS parsing error: Failed to convert 字体加载失败

    字体文件,加载不出来 解决方案  一 问题是Maven正在过滤字体文件并破坏它们. <resource> <directory>${project.basedir}/src/m ...

  3. 处理springboot OTS parsing error: Failed to convert WOFF 2.0 font to SFNT

    springboot项目中添加了字体等文件后,页面无法识别,浏览器调试窗口报错如下: Failed to decode downloaded font: http://localhost:8080/f ...

  4. 解决Spring Boot OTS parsing error: Failed to convert WOFF 2.0

    <build> <resources> <resource> <directory>${project.basedir}/src/main/resour ...

  5. chrome浏览器警告:Failed to decode downloaded font:

    使用iconfont字体时chrome报错 Failed to decode downloaded font: 在服务器设置一下自己定义MIME类型. 扩展名: .woff Mime类型:applic ...

  6. Failed to decode downloaded font

    碰到如下错误,该错误是开启layui的打印.导出.筛选列时出现的,不能正常显示图标及文字 原因: @参考文章 因为经过maven的filter,会破坏font文件的二进制文件格式,到时前台解析出错 解 ...

  7. 记一次elementUI Icon 加载无效的问题。并且提示错误 Failed to decode downloaded font:

    问题在于webpack的loader中.检查了一下发现有两个相同的file-loader的配置,删除其中一个即可.

  8. URIError: Failed to decode param '/%PUBLIC_URL%/favicon.ico'

    今天搭建antd的项目结构,本来项目是一个基础react项目,结果执行 yarn create umi yarn yarn start 项目启动后访问突然报错URIError: Failed to d ...

  9. composer 报错:Failed to decode response: zlib_decode(): data error 解决办法

    执行命令 composer require particle/validator 报错 Failed to decode response: zlib_decode(): data error 网上推 ...

随机推荐

  1. vue-learning:38 - router - 前端路由的发展

    前端路由的发展 参考博客 前端路由是什么东西? 什么是路由 在jQuery时代,我们使用<a href="https://www.example.com/example/home.ht ...

  2. Linux 内核管理类

    一个类由一个 struct class 的实例来定义: struct class { char *name; struct class_attribute *class_attrs; struct c ...

  3. 在eclipse动态网页项目中,编写web.xml时,servlet标签报错.

    cvc-complex-type.2.4.b: The content of element 'servlet' is not complete. One of '{"http:// jav ...

  4. 2018-2-13-WPF-异常-NativeWPFDLLLoader.LoadNativeWPFDLL

    title author date CreateTime categories WPF 异常 NativeWPFDLLLoader.LoadNativeWPFDLL lindexi 2018-2-13 ...

  5. [板子]用线段树解决ST表问题

    ST表可以参考:http://blog.csdn.net/whistlena/article/details/52191463 简单说就是区间RMQ最值问题. 对解决这种问题,线段树不用用啥啊. 扔一 ...

  6. codeforces gym100801 Problem J. Journey to the “The World’s Start”

    传送门:https://codeforces.com/gym/100801 题意: 小明坐地铁,现在有n-1种类型的地铁卡卖,现在小明需要买一种地铁票,使得他可以在t的时间内到达终点站,地铁票的属性为 ...

  7. springmvc 参数校验/aop失效/@PathVariable 参数为空

    添加依赖 <!-- 参数校验 --> <dependency> <groupId>org.hibernate.validator</groupId> & ...

  8. 驳“C语言已经死了”

    http://blog.csdn.net/xushiweizh/article/details/1476422

  9. slim中的请求URI

    请求 URI 每个 HTTP 请求都有一个识别被请求的应用程序资源的 URI .HTTP 请求 URI 分为这几部分: Scheme (e.g. http or https) Host (e.g. e ...

  10. HDU 2068 RPG错排 [错排公式]

    1.题意:1到N的序列的排列中,元素位置与元素值相对应的情况(值为i的元素在某个排列中正好排在第i个位置)大于等于序列规模一半的情况,有多少个? 2.输入输出:每组数据一个数,N,规定输入以0结尾: ...