为什么会出现“元素h:head未绑定的前缀h”错误?

And*_*eth 2 html xhtml jsf

这是我的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>
Run Code Online (Sandbox Code Playgroud)

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

这让我疯狂。为什么会出现此错误?

jkl*_*lee 5

您需要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>
Run Code Online (Sandbox Code Playgroud)