昨晚,在做一个自己感兴趣的东西时,发现浏览器报警告,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. MySQL Workbench: mysqldump version mismatch

    Windows10 64bit系统下,步骤就是: Edit --> preferences --> Administrator --> Path to mysqldump tool: ...

  2. vue项目导入excel单列导入

    先安装 xlsx.js, 然后引入 import XLSX from 'xlsx'; 代码 <form> <span> <textarea name="cont ...

  3. C# 判断系统版本

    本文告诉大家如何判断系统是 win7 还是 xp 系统 使用下面代码可以判断 private static readonly Version _osVersion = Environment.OSVe ...

  4. jQuery 工具类函数-使用$.extend()扩展Object对象

    除使用$.extend扩展工具函数外,还可以扩展原有的Object对象,在扩展对象时,两个对象将进行合并,当存在相同属性名时,后者将覆盖前者,调用格式为: $. extend (obj1,obj2,… ...

  5. 彻底弄懂slice和splice的区别

    总觉得数组和字符串中的一些方法的使用很难记,可能是日常都是在学理论,缺少实际应用.不多说了,继续学习吧! 一句话先提前概括: slice(start,end) 从哪到哪开始删 splice(strt, ...

  6. jdk+tomcat+mysql一键安装脚本

    最近在搞一个web项目部署,每次都要安装jdk.配置环境变量.安装tomcat和mysql.对于非开发人员,还是有点难度的,经常出错,然后就整理了一个自动化的脚本. JDKinstall.bat @e ...

  7. 大数据vs计算机

    大数据有两个方向,一个是偏计算机的,另一个是偏经济的.你学过Java,所以你可以偏将计算机 基础1. 读书<Introduction to Data Mining>,这本书很浅显易懂,没有 ...

  8. VIM 用正则表达式,非贪婪匹配,匹配竖杠,竖线, 匹配中文,中文正则,倒数第二列, 匹配任意一个字符 :

    VIM 用正则表达式 批量替换文本,多行删除,复制,移动 在VIM中 用正则表达式 批量替换文本,多行删除,复制,移动 :n1,n2 m n3     移动n1-n2行(包括n1,n2)到n3行之下: ...

  9. HDU 2102 A计划 DFS与BFS两种写法 [搜索]

    1.题意:一位公主被困在迷宫里,一位勇士前去营救,迷宫为两层,规模为N*M,迷宫入口为(0,0,0),公主的位置用'P'标记:迷宫内,'.'表示空地,'*'表示墙,特殊的,'#'表示时空传输机,走到这 ...

  10. 大数据hadoop集群部署(一)

     环境系统配置  JAVA虚拟机的安装