网上找了很多关于font-awesome在ie8中不显示的解决办法,但是都没有效果,最后尝试把本地能够在ie8中正常显示字体的demo移植到spring-boot中发现在ie8中就是显示不了,所以得出结论font-awesome在ie8中字体不显示应该和框架的配置有关系,网上找到了解决方法如下
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.woff</exclude>
<exclude>**/*.ttf</exclude>
<exclude>**/*.eot</exclude>
<exclude>**/*.svg</exclude>
</excludes>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.woff</include>
<include>**/*.ttf</include>
<include>**/*.eot</include>
<include>**/*.svg</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>woff</nonFilteredFileExtension>
<nonFilteredFileExtension>eot</nonFilteredFileExtension>
<nonFilteredFileExtension>ttf</nonFilteredFileExtension>
<nonFilteredFileExtension>svg</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
</plugins>
</build>
首先在resource中添加了exclude和include,尝试没有效果,然后再配置了maven-resources-plugin,图标在ie8中终于能显示出来了,感动的热泪盈眶,至于上面配置的exclude和include可不可以删掉懒得测试了。
然后还发现一个问题,我的font-awesome.css配置如下,同事电脑中没有src: url('../fonts/fontawesome-webfont.eot');这一行代码也会显示不出来
@font-face {
font-family: 'FontAwesome';
src: url('../fonts/fontawesome-webfont.eot');
src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.2.0') format('embedded-opentype');
src: url('../fonts/fontawesome-webfont.eot?v=4.2.0'), url('../fonts/fontawesome-webfont.woff?v=4.2.0') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.2.0') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.2.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal
}