javax.faces.view.facelets.FaceletException:错误解析/my.xhtml:错误跟踪[行:42]前缀"f"表示错误.对于元素"f:facet"没有约束 [英] javax.faces.view.facelets.FaceletException: Error Parsing /my.xhtml: Error Traced[line: 42] The prefix "f" for element "f:facet" is not bound

查看:325
本文介绍了javax.faces.view.facelets.FaceletException:错误解析/my.xhtml:错误跟踪[行:42]前缀"f"表示错误.对于元素"f:facet"没有约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个表,该表可以将数据库中的数据显示到JSF页面中.我找到了以下代码:

I would like to create table which can display data from database into JSF page. I found this code:

<h:dataTable value="#{bookStore.items}" var="store">
  <h:column>
    <f:facet name="header">
      <h:outputText  value="#{msg.storeNameLabel}"/>
    </f:facet>
    <h:outputText value="#{store.name}"/>
  </h:column>
  <h:column>
    <f:facet name="header">
      Subject
    </f:facet>
    <h:outputText value="#{store.subject}"/>
  </h:column>
  <h:column>
    <f:facet name="header">
      <h:outputText  value="#{msg.storePriceLabel}"/>
    </f:facet>
    <h:outputText value="#{store.price}"/>
  </h:column>
</h:dataTable> 

使用此代码时,我在Netbeans中收到以下错误消息:

When I use this code I get this error message in Netbeans:

javax.faces.view.facelets.FaceletException:错误解析/my.xhtml:错误跟踪[行:42]元素"f:facet"的前缀"f"未绑定

javax.faces.view.facelets.FaceletException: Error Parsing /my.xhtml: Error Traced[line: 42] The prefix "f" for element "f:facet" is not bound

如果我将f标记替换为h标记,它将起作用吗?还是我必须包含f标记库?

If I replace the f tag with h tag, is it going to work? Or do I have to include f tag library?

推荐答案

您必须为f前缀包含正确的taglib.

You have to inlude the correct taglib for the f prefix.

以下是JSF 2.2 Facelet页面的示例:

Here is an example for a JSF 2.2 Facelet page:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

...
</html>

如果您仍在使用JSF 2.0/2.1,请在XML名称空间中使用java.sun.com域而不是xmlns.jcp.org域.

In case you're still on JSF 2.0/2.1, use java.sun.com domain instead of xmlns.jcp.org domain in XML namespace.

我建议阅读JSF教程,您可以在我们的JSF Wiki页面中找到链接.

I recommend to read a JSF tutorial, you can find links in our JSF wiki page.

这篇关于javax.faces.view.facelets.FaceletException:错误解析/my.xhtml:错误跟踪[行:42]前缀"f"表示错误.对于元素"f:facet"没有约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆