PrimeFaces Atlas主题升级Font Awesome 5遇EL表达式解析异常求助
PrimeFaces Atlas主题升级Font Awesome 5.0.10的问题解决指南
我来帮你拆解下你遇到的这个问题:你看到的EL解析异常,核心原因是表达式里的转义单引号'不符合EL语法规范,再加上Font Awesome 5和4的文件结构差异,才导致了报错。下面是具体的解决步骤:
1. 先修复EL表达式语法错误
异常里的表达式#{resource['atlas-layout:fonts/fa-brands-400.eot]}有两个问题:
- 用了HTML转义的
',EL中应该直接使用普通单引号 - 表达式末尾缺少闭合的
]}
你需要找到Atlas主题中引用字体的CSS文件(通常是atlas-layout相关的样式文件),把所有类似的资源引用替换成正确格式:
// 错误写法 src: url('#{resource['atlas-layout:fonts/fa-brands-400.eot]}'); // 正确写法 src: url('#{resource['atlas-layout:fonts/fa-brands-400.eot']}');
2. 适配Font Awesome 5的文件结构
Font Awesome 5和4的字体文件结构差异很大:
- 4.x是单一大字体文件,5.x拆分了
brands(品牌图标)、solid(实心图标)、regular(空心图标)等独立字体包 - 确保你已经把Font Awesome 5.0.10的所有相关字体文件(
fa-brands-400.*、fa-solid-900.*、fa-regular-400.*)放到了atlas-layout/fonts/目录下,路径要和CSS里的引用完全匹配
3. 更新CSS中的@font-face规则
Font Awesome 5的字体家族命名和4.x不一样,你需要替换主题中原有的@font-face定义,改为5.x对应的规则:
/* 品牌图标字体 */ @font-face { font-family: 'Font Awesome 5 Brands'; font-display: block; src: url('#{resource['atlas-layout:fonts/fa-brands-400.eot']}'); src: url('#{resource['atlas-layout:fonts/fa-brands-400.eot']}?#iefix') format('embedded-opentype'), url('#{resource['atlas-layout:fonts/fa-brands-400.woff2']}') format('woff2'), url('#{resource['atlas-layout:fonts/fa-brands-400.woff']}') format('woff'), url('#{resource['atlas-layout:fonts/fa-brands-400.ttf']}') format('truetype'); } /* 实心图标字体(900是权重) */ @font-face { font-family: 'Font Awesome 5 Free'; font-weight: 900; font-display: block; src: url('#{resource['atlas-layout:fonts/fa-solid-900.eot']}'); src: url('#{resource['atlas-layout:fonts/fa-solid-900.eot']}?#iefix') format('embedded-opentype'), url('#{resource['atlas-layout:fonts/fa-solid-900.woff2']}') format('woff2'), url('#{resource['atlas-layout:fonts/fa-solid-900.woff']}') format('woff'), url('#{resource['atlas-layout:fonts/fa-solid-900.ttf']}') format('truetype'); }
4. 更新图标类名(重要)
Font Awesome 5的图标类前缀也变了,你需要检查主题中所有硬编码的图标类:
- 品牌图标:从
fa fa-github改为fab fa-github - 实心图标:从
fa fa-check改为fas fa-check - 空心图标:从
fa fa-star改为far fa-star
5. 清理缓存避免旧资源干扰
最后别忘了:
- 清理应用服务器的缓存(比如Tomcat的
work目录) - 清空浏览器缓存,强制刷新页面,确保新的字体和CSS文件被正确加载
内容的提问来源于stack exchange,提问作者Gopi Lal
相关产品推荐
相关产品推荐

