具有命名空间的元素http://xmlns.jcp.org/jsf/html 命名空间中可能没有属性http://xmlns.jcp.org/jsf

具有命名空间的元素http://xmlns.jcp.org/jsf/html 命名空间中可能没有属性http://xmlns.jcp.org/jsf,jsf,namespaces,Jsf,Namespaces,我正在使用所有的JSF2.2新名称空间 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:jsf="http://xmlns.jcp.org/jsf" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsp/jstl/core"&g

我正在使用所有的JSF2.2新名称空间

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

但是,当我收到此错误时,我尝试将component selectOneMenu与selectItem一起使用的次数是多少:

HTTP状态500-具有命名空间的元素 命名空间中可能没有属性 . 名称空间是 用于其他方面不支持JSF的标记,例如,使用它是无效的

这是我的SelectOne功能表:

<h:selectOneMenu class="form-control"
    id="selectOlhos" jsf:value="#{corpoController.corpo.corOlhos}">
        <f:selectItem  itemLabel="Escolha" itemValue=""></f:selectItem>
        <f:selectItem  itemLabel="Verdes Claros" itemValue="Verdes Claros"></f:selectItem>
        <f:selectItem  itemLabel="Verdes Escuros" itemValue="Verdes Escuros"></f:selectItem>
        <f:selectItem  itemLabel="Castanhos Claros" itemValue="Castanhos Claros"></f:selectItem>
        <f:selectItem  itemLabel="Castanhos Escuros" itemValue="Castanhos Escuros"></f:selectItem>  
</h:selectOneMenu>

如果我移除这个组件,它会工作得很好。 有什么帮助吗

具有命名空间的元素在命名空间中可能没有属性。名称空间用于其他不支持JSF的标记,例如,使用名称空间是无效的

错误的字面意思是,您不能在
元素中使用
jsf:xxx
属性

我不知道怎样才能解释得更清楚。错误基本上是说
jsf:xxx
属性应该只用于普通的HTML元素,比如
元素不支持
jsfxxx
属性

在您的具体案例中,这是错误的:

<h:selectOneMenu ... jsf:value="...">

相反,您必须使用:

<h:selectOneMenu ... value="...">

或者,如果您确实想将
用作所谓的HTML格式,那么您应该使用纯HTML

<select ... jsf:value="...">

另见:

好主意!;-)