[Maven 編譯] fontawesome 問題: Failed to decode downloaded font


使用maven 編譯WEB項目時,按鈕上的圖標不顯示(使用http://fontawesome.io/icons/)

在瀏覽器console中打印錯誤:OTS parsing error: incorrect entrySelector for table directory 1 Failed to decode downloaded font: https://my-address.com/css/fonts/robot...

 

原因:使用maven-resources-plugin copy 靜態資源時,如果有<filtering>true</filtering>標簽,會破壞fontawesome 中的文件

  

<resources>
    <resource>
        <directory>${project.basedir}/src/main/webapp</directory>
	<targetPath>${project.build.directory}</targetPath>
	<filtering>true</filtering>
</resources>    

 

 

解決辦法:

(1) 將 <filtering>true</filtering> 改為false

 (2)

<resources>
  <resource>
    <directory>${project.basedir}/src/main/webapp</directory>
    <targetPath>${project.build.directory}</targetPath>
    <filtering>true</filtering>
    <excludes>
      <exclude>**/*.woff</exclude>
      <exclude>**/*.ttf</exclude>
      <exclude>**/*.woff2</exclude>
      <exclude>**/*.otf</exclude>
      <exclude>**/*.eot</exclude>
      <exclude>**/*.svg</exclude>
    </excludes>
  </resource>
  <resource>
    <directory>${project.basedir}/src/main/webapp</directory>
    <targetPath>${project.build.directory}</targetPath>
    <filtering>false</filtering>
    <includes>
      <include>**/*.woff</include>
      <include>**/*.ttf</include>
      <include>**/*.woff2</include>
      <include>**/*.otf</include>
      <include>**/*.eot</include>
      <include>**/*.svg</include>
    </includes>
  </resource>
</resources>

 

參考:http://stackoverflow.com/questions/32690418/i-cant-load-fonts-while-using-tomcat

         http://stackoverflow.com/questions/32475982/fontawesome-fails-to-load-fonts-locally-and-in-electron-app


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM