我使用 JSF2 和 Maven 3 开发一个 Web 应用程序。在我的应用程序中,我使用自定义字体,并在 css 中包含以下代码:
@font-face {
font-family: 'another_shabby';
src: url("#{resource['fonts:anothershabby_trial-webfont.eot']}");
src: url("#{resource['fonts:anothershabby_trial-webfont.eot']}?#iefix")
format('embedded-opentype'),
url("#{resource['fonts:anothershabby_trial-webfont.woff']}")
format('woff'),
url("#{resource['fonts:anothershabby_trial-webfont.ttf']}")
format('truetype'),
url("#{resource['fonts:anothershabby_trial-webfont.svg']}#WebSymbolsRegular")
format('svg');
font-weight: normal;
font-style: normal;}
Run Code Online (Sandbox Code Playgroud)
字体文件位于我的resources文件夹中的目录中:webapp/resources/fonts
现在,我遇到了一个似乎是由 Maven 引起的问题......
我在 Maven 中添加了一个过滤器来解析 web.xml,以便javax.faces.PROJECT_STAGE根据 Maven 配置文件在开发和生产之间动态切换上下文参数。
这是我的 pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
<profile>
<id>dev</id>
<properties>
<jsfProjectStage>Development</jsfProjectStage>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
Run Code Online (Sandbox Code Playgroud)
web.xml:
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>${jsfProjectStage}</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
当我使用此配置时,字体未正确加载,但如果我删除 pom 中的过滤器并且 context-param 为“硬编码”,则一切正常...我在 …