Html 为什么我会得到;元素h的前缀h:head未绑定“;错误?

Html 为什么我会得到;元素h的前缀h:head未绑定“;错误?,html,jsf,xhtml,Html,Jsf,Xhtml,这是我的xhtml文件: <html> <h:head> <meta http-equiv="Content-Type" content="text/html; charset=Cp1252"/> </h:head> <h:body> <view> <h:form> <br/> <br/>

这是我的xhtml文件:

<html>
<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=Cp1252"/>
</h:head>

<h:body>
    <view>
        <h:form>
            <br/>
            <br/>

            <center>
                <h:panelGrid columns="2">
                    <f:facet name="header">
                        <h:outputText value="Login"/>
                    </f:facet>

                    <h:outputText value="Benutzername:"/>
                    <h:inputText value="#{benutzer.benutzerName}" size="18"/>
                    <h:outputText value="Passwort: "/>
                    <h:inputSecret value="#{benutzer.passwort}" size="18"/>

                    <f:facet name="footer">
                        <h:commandButton value="Login" action ="#{benutzer.doLogin}"/>
                    </f:facet>
                </h:panelGrid >
            </center>
        </h:form>
    </view>
</h:body>



每次尝试运行它时,都会出现错误“元素h的前缀h:head未绑定”


这快把我逼疯了。为什么会出现此错误?

您需要h名称空间

<!DOCTYPE HTML>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">
<h:head>
...
</h:head>
<h:body>
...
</h:body>
</html>

...
...