我正在尝试在 jsf 2.2 中使用 bootstrap 和 glypicons 制作一个简单的页面。我已经包含了 webjar 的引导依赖项(打开 jar 我可以看到字体文件存在)。
将应用程序部署到 wildfly 时,引导 css 可以正常工作,但显示的图标很糟糕(例如默认字体或其他内容)。查看浏览器中的网络选项卡,我只看到 404 错误:
http://localhost:8080/proto/javax.faces.resource/bootstrap/3.1.1/fonts/glyphicons-halflings-regular.woff 404
http://localhost:8080/proto/javax.faces.resource/bootstrap/3.1.1/fonts/glyphicons-halflings-regular.ttf 404
我尝试包含其他依赖项(bootstrap-glypicons),但只收到 404 错误两次。我缺少什么?
这就是我添加 boostrap 的方式,它对于 css 可以正常工作:
<h:outputStylesheet library="webjars" name="bootstrap/3.1.1/css/bootstrap.min.css" />
这就是我使用 css 类的方式:
<button><span class="glyphicon glyphicon-minus"></span></button>
你应该使用<link>
标签而不是<h:outputStylesheet>
eg.
<link rel="stylesheet" type="text/css" media="all" href="webjars/bootstrap/3.1.1/css/bootstrap.min.css"/>
- - 更新
发生这种情况是因为 JSF 中的 ResourceHandler 将库值 (webjars) 添加到 URI 的末尾作为参数:
faces/javax.faces.resource/bootstrap/3.1.1/css/bootstrap.min.css?ln=webjars
在 bootstrap.min.css CSS 中有这样的文件引用:
url('../fonts/glyphicons-halflings-regular.woff') 格式('woff'), url('../fonts/glyphicons-halflings-regular.ttf') 格式('truetype'),
所以如果你想使用<h:outputStylesheet>
你可以编写自己的ResourceHander或者你可以编辑bootstrap.min.css
并修复路径glyphicons-halflings-regular.*
files
我认为最好使用标准 html 标签<link>
代替<h:outputStylesheet>
因为 JSF 组件树会更小并且会影响性能。里面bootstrap.min.css
没有EL所以不需要使用<h:outputStylesheet>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)