在html文件使用字体图标并且预览时正常,但是启动工程后显示不正常,浏览器调试界面显示字体文件无法decode:

Failed to decode downloaded font: xxxxx

如图所示:

Spring Boot使用layui的字体图标时无法正常显示解决办法

显示结果:

Spring Boot使用layui的字体图标时无法正常显示解决办法

原因:经过maven的filter,会破坏font文件的二进制文件格式,导致前台解析出错。

解决办法:在pom文件中配置maven的filter,在<build>标签内添加如下配置:


       <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <!--<exclude>reference</exclude>-->
                    <exclude>static/**/*</exclude>
                    <!--<exclude>MyBatisGeneratorConfig.xml</exclude>-->
                </excludes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>static/**/*</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>


然后清除服务端缓存(mvn clean)与浏览器缓存即可


相关文章:

  • 2022-12-23
  • 2021-09-13
  • 2021-12-07
  • 2021-12-15
  • 2021-10-29
  • 2021-06-06
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2021-06-17
  • 2021-10-09
  • 2021-05-19
  • 2021-11-23
  • 2022-12-23
  • 2021-10-29
  • 2021-08-02
相关资源
相似解决方案