我在使用tomcat时无法加载字体

Gre*_*ber 4 fonts tomcat font-awesome

使用tomcat时加载字体时出现此类错误:

1无法解码下载的字体:https://my-address.com/css/fonts/robotocondensed-bold-webfont.woff2

1 OTS解析错误:无法将WOFF 2.0字体转换为SFNT

1无法解码下载的字体:https://my-address.com/css/fonts/robotocondensed-regular-webfont.woff2

1 OTS解析错误:无法将WOFF 2.0字体转换为SFNT

1无法解码下载的字体:https://my-address.com/css/fonts/fontawesome-webfont.woff2?v = 4.3.0

1 OTS解析错误:无法将WOFF 2.0字体转换为SFNT

1无法解码下载的字体:https://my-address.com/css/fonts/robotocondensed-regular-webfont.woff

1 OTS解析错误:WOFF标头中的文件大小不正确

1无法解码下载的字体:https://my-address.com/css/fonts/robotocondensed-bold-webfont.woff

1 OTS解析错误:WOFF标头中的文件大小不正确

https:// fake .com /无法加载资源:net :: ERR_BLOCKED_BY_CLIENT

1无法解码下载的字体:https://my-address.com/css/fonts/robotocondensed-regular-webfont.ttf

1 OTS解析错误:FFTM:未对齐的表

1无法解码下载的字体:https://my-address.com/css/fonts/fontawesome-webfont.woff?v = 4.3.0

1 OTS解析错误:WOFF标头中的文件大小不正确

1无法解码下载的字体:https://my-address.com/css/fonts/robotocondensed-bold-webfont.ttf

1 OTS解析错误:GDEF:未对齐的表

1无法解码下载的字体:https://my-address.com/css/fonts/fontawesome-webfont.ttf?v = 4.3.0

1 OTS解析错误:表目录的entrySelector不正确

1无法解码下载的字体:https://my-address.com/css/fonts/robotocondensed-light_0-webfont.woff2

1 OTS解析错误:无法将WOFF 2.0字体转换为SFNT

1无法解码下载的字体:https://my-address.com/css/fonts/robotocondensed-light_0-webfont.woff

1 OTS解析错误:WOFF标头中的文件大小不正确

1无法解码下载的字体:https://my-address.com/css/fonts/robotocondensed-light_0-webfont.ttf

1 OTS解析错误:FFTM:无效的表偏移量

从spring-boot开始我没有这个错误.正确的文件位于https://my-address.com/css/fonts/文件夹中.并且应该加载的字体无法正确显示.我能修复什么才能使它有效?

Mik*_*ail 9

如果您使用maven-resources-plugin来复制带有选项的webapp静态资源(包括字体),<filtering>true</filtering>那么它可能是资源损坏的原因.

在这种情况下,您可以将过滤设置为false(示例):

<plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>copy-frontend-resources</id>
                       <phase>process-resources</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/target/classes/static</outputDirectory>
                        <resources>
                            <resource>
                                <directory>${basedir}/target/build</directory>

                                <filtering>false</filtering> <!-- SET TO FALSE TO PREVENT RESOURCES CORRUPTION -->

                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

有关maven资源过滤的更多信息

另一种方法是从过滤中排除资源(参见下面的@eppsilon评论).