【问题标题】:Elements with namespace http://xmlns.jcp.org/jsf/html may not have attributes in namespace http://xmlns.jcp.org/jsf具有命名空间 http://xmlns.jcp.org/jsf/html 的元素可能在命名空间 http://xmlns.jcp.org/jsf 中没有属性
【发布时间】:2018-08-19 05:55:18
【问题描述】:

我正在使用所有 jsf 2.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">

但是我尝试将组件 selectOneMenu 与 selectItem 一起使用多少我收到此错误:

HTTP 状态 500 - 具有命名空间的元素 http://xmlns.jcp.org/jsf/html 可能在命名空间中没有属性 http://xmlns.jcp.org/jsf。命名空间http://xmlns.jcp.org/jsf 是 用于其他不支持 JSF 的标记,例如 .

这是我的 selectOneMenu:

<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 namespaces


【解决方案1】:

命名空间http://xmlns.jcp.org/jsf/html 的元素在命名空间http://xmlns.jcp.org/jsf 中可能没有属性。命名空间 http://xmlns.jcp.org/jsf 用于其他非 JSF 感知标记,例如 具有 无效。

该错误字面意思是您不能在&lt;h:xxx&gt; 元素中使用jsf:xxx 属性。

我不确定如何才能更清楚地解释这一点。该错误基本上表明jsf:xxx 属性只能用于纯HTML 元素,例如&lt;div&gt;&lt;h:xxx&gt; 元素不支持 jsfxxx 属性。

在您的具体情况下,这是错误的:

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

相反,您必须使用:

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

或者,如果您真的想将&lt;h:selectOneMenu&gt; 用作所谓的passthrough element,那么您应该使用纯 HTML &lt;select&gt;

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

另见:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-18
    • 1970-01-01
    • 1970-01-01
    • 2014-10-26
    • 2015-08-31
    • 2014-05-16
    • 2014-12-26
    • 2019-06-02
    相关资源
    最近更新 更多