作为测试,创建一个包含 和 PrimeFaces 组件的页面,在网络浏览器中打开该页面并通过右键单击检查生成的 HTML 源 - < em>查看源代码。您将看到添加了几个 JSF 和 PrimeFaces 特定的 JS/CSS 文件。现在将 替换为 并再次检查生成的 HTML 源代码,这次您将看不到任何内容。
The <h:head> is a JSF component which provides a hook to programmatically include JavaScript and CSS resources in the generated HTML <head>. PrimeFaces uses it to include the necessary JS/CSS code for the Ajax works and fancy look'n'feel.
As a test, create a page with a <h:head> and a PrimeFaces component, open the page in the webbrowser and check the generated HTML source by rightclick - View Source. You'll see that several JSF and PrimeFaces specific JS/CSS files are been added. Now replace <h:head> by <head> and check the generated HTML source once again, you'll see nothing this time.
The <head> tag is a HTML tag, which defines the head of the HTML page (this is where you define metadata, or include the resources such as JavaScript or CSS for example).
The <h:head> is a JSF tag (introduced with JSF 2.0) that handles the <head> part of your page. The interest of having such JSF tag is that this head becomes part of your JSF components tree, and thus, you can manipulate it in your Java code.
Regarding the <head> incompatibility with Primefaces, I don't see why it happens. Facelets introduced in JSF 1.x the ability to mix HTML code and JSF (XHTML) code, and you should not have any trouble to insert a HTML <head> tag in your page, even if you use Primefaces. Facelets is natively integrated with JSF 2.x.
发布评论
评论(2)
是一个 JSF 组件,它提供了一个挂钩,以编程方式在生成的 HTML中包含 JavaScript 和 CSS 资源。 PrimeFaces 使用它来包含 Ajax 工作和精美外观所需的 JS/CSS 代码。
作为测试,创建一个包含
和PrimeFaces
组件的页面,在网络浏览器中打开该页面并通过右键单击检查生成的 HTML 源 - < em>查看源代码。您将看到添加了几个 JSF 和 PrimeFaces 特定的 JS/CSS 文件。现在将
替换为并再次检查生成的 HTML 源代码,这次您将看不到任何内容。
The
<h:head>
is a JSF component which provides a hook to programmatically include JavaScript and CSS resources in the generated HTML<head>
. PrimeFaces uses it to include the necessary JS/CSS code for the Ajax works and fancy look'n'feel.As a test, create a page with a
<h:head>
and aPrimeFaces
component, open the page in the webbrowser and check the generated HTML source by rightclick - View Source. You'll see that several JSF and PrimeFaces specific JS/CSS files are been added. Now replace<h:head>
by<head>
and check the generated HTML source once again, you'll see nothing this time.标记是 HTML 标记 ,它定义 HTML 页面的头部(这是您定义元数据的位置,或者包括 JavaScript 或 CSS 等资源)。
是一个 JSF 标记(随 JSF 2.0 引入),用于处理页面的部分。拥有这样的 JSF 标签的好处是,这个头成为 JSF 组件树的一部分,因此,您可以在 Java 代码中操作它。
关于
与 Primefaces 不兼容,我不明白为什么会发生这种情况。 Facelets 在 JSF 1.x 中引入了混合 HTML 代码和 JSF (XHTML) 代码的能力,并且您在页面中插入 HTML
标记应该不会有任何问题,即使您使用 Primefaces。 Facelets 本身就与 JSF 2.x 集成。
<head>
tag is a HTML tag, which defines the head of the HTML page (this is where you define metadata, or include the resources such as JavaScript or CSS for example).<h:head>
is a JSF tag (introduced with JSF 2.0) that handles the<head>
part of your page. The interest of having such JSF tag is that this head becomes part of your JSF components tree, and thus, you can manipulate it in your Java code.Regarding the
<head>
incompatibility with Primefaces, I don't see why it happens. Facelets introduced in JSF 1.x the ability to mix HTML code and JSF (XHTML) code, and you should not have any trouble to insert a HTML<head>
tag in your page, even if you use Primefaces. Facelets is natively integrated with JSF 2.x.