这是Facelet:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


 <html xmlns ="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">

 <h:head>
 <title>Title</title>
 </h:head>

 <h:body>
 <h:form>
 <h:commandButton value ="Converter" action ="#{conversorMonetarioBean.converte}"/>
 <h:inputText value ="#{conversorMonetarioBean.valor}"/>

 <h:outputLabel value ="de" for ="de"/>

 <h:selectOneMenu value ="#{conversorMonetarioBean.de}" id="de">
 <f:selectItems
    value ="#{conversorMonetarioBean.taxas.keySet()}"
    var ="moeda"
    itemValue ="#{moeda}"
    itemLabel ="#{moeda}" />
 </h:selectOneMenu>

 <h:outputLabel value ="para" for ="para"/>

 <h:selectOneMenu value ="#{conversorMonetarioBean.para}" id="para">
 <f:selectItems
     value ="#{conversorMonetarioBean.taxas.keySet()}"
     var ="moeda"
     itemValue ="#{moeda}"
     itemLabel ="#{moeda}"  />
 </h:selectOneMenu>
 </h:form>



<h:outputFormat value ="{0} em {1} equivale a {2} em {3}" rendered ="#{conversorMonetarioBean.resultado != null}">
 <f:param value ="#{conversorMonetarioBean.valor}"/>
 <f:param value ="#{conversorMonetarioBean.de}"/>
 <f:param value ="#{conversorMonetarioBean.resultado}"/>
 <f:param value ="#{conversorMonetarioBean.para}"/>
 </h:outputFormat>
</h:body>
</html>

据说f:selectItems是一个未知标记。

有什么问题吗?我正在使用JSF2,GlassFish 3.1.2,Eclipse。我试图按Ctrl +空格键,但只有h:something标签。

最佳答案

您忘记了在f声明html中导入xmlns:f="http://java.sun.com/jsf/core"命名空间,因此顶部如下所示:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

另外,您的IDE可能会向您显示f命名空间丢失的提示,因此按照其指示进行导入将解决您的问题。

关于jsf-2 - 未知标记.xhtml jsf <f:selectItems/>,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16502982/

10-16 02:56