gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 17:01:58 27 4
gpt4 key购买 nike

我正在使用所有 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 Status 500 - Elements with namespace http://xmlns.jcp.org/jsf/html may not have attributes in namespace http://xmlns.jcp.org/jsf. Namespace http://xmlns.jcp.org/jsf is intended for otherwise non-JSF-aware markup, such as <input type="text" jsf:id > It is not valid to have <h:commandButton jsf:id="button" />.



这是我的 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>

如果我删除此组件,它将完美运行。
有什么帮助吗?

最佳答案

Elements with namespace http://xmlns.jcp.org/jsf/html may not have attributes in namespace http://xmlns.jcp.org/jsf. Namespace http://xmlns.jcp.org/jsf is intended for otherwise non-JSF-aware markup, such as <input type="text" jsf:id > It is not valid to have <h:commandButton jsf:id="button" />.



该错误字面意思是您可能不使用 jsf:xxx <h:xxx> 中的属性元素。

我不确定如何更清楚地解释这一点。错误基本上是说 jsf:xxx属性只能用于纯 HTML 元素,例如 <div> . jsfxxx <h:xxx> 不支持属性元素。

在您的具体情况下,这是错误的:
<h:selectOneMenu ... jsf:value="...">

相反,您必须使用:
<h:selectOneMenu ... value="...">

或者,如果您确实想使用 <h:selectOneMenu>作为所谓的 passthrough element ,那么你应该使用纯 HTML <select>反而。
<select ... jsf:value="...">

也可以看看:
  • <a jsf:rendered="#{...}"> is not interpreted as passthrough element
  • Which XML namespace to use with JSF 2.2
  • 关于jsf - 命名空间为 http ://xmlns. jcp.org/jsf/html 的元素可能没有命名空间 http ://xmlns. jcp.org/jsf 中的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49214453/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com