我在 GlassFish 3.2 上使用 NetBeans 7.3.1 和 PrimeFaces 3.5。
我用 PrimeFaces 组件创建了一个 JSF 页面。该项目运行良好,但 PrimeFaces UI 外观完全缺失。我只注意到服务器日志中的以下消息:
One or more resources has the target of 'head' but not 'head' component has been defined within the view
这是什么意思,我该如何修复 PrimeFaces UI 的外观?
最佳答案
这意味着您使用的是纯 HTML <head>
而不是 JSF <h:head>
在您的 XHTML 模板中。 JSF <h:head>
允许在生成的 HTML 中自动包含 CSS/JS 资源 <head>
通过 @ResourceDependency
注释。 PrimeFaces 作为基于 jQuery 的 JSF 组件库需要自动包含一些 jQuery/UI JS/CSS 文件,这确实需要 <h:head>
.
所以,寻找一个
<head>
<title>Some title</title>
...
</head>
在您的模板中并将其替换为
<h:head>
<title>Some title</title>
...
</h:head>
也可以看看:
关于user-interface - 一个或多个资源的目标为 'head' 但未在 View 中定义 'head' 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18940644/