我有一个简单的表单页面,如下所示:
<f:view contentType="text/html">
<h:head>
<title>Login Page</title>
</h:head>
<body>
<h1>Java Learning Center</h1><hr id="horizontalLine"/>
<h2><a>Account Login</a></h2>
<h:outputText value="#{userBean.errorMessage}" style="color:red; text-size:20" />
<h:form>
<h:panelGrid>
<h:outputText value="Username" />
<h:inputText value="#{userBean.username}" id="username" required="true" />
<h:message for="username" style="color:red; text-size:18"/>
<h:outputText value="Password" />
<h:inputSecret value="#{userBean.password}" id="password" required="true"/>
<h:message for="password" style="color:red; text-size:18"/>
<h:commandButton value="Login" action="#{userBean.verifyUser}" />
</h:panelGrid>
</h:form>
</body>
</f:view>
</html>当我将其部署到Tomcat7时,将显示完整页面。但是,当我在JBoss6.1Runtime上部署时,没有显示与JSF的HTML标记库对应的表单元素。我只看到来自<h1>和<h2>等普通HTML元素的内容。
我在哪里犯了错?
发布于 2014-08-18 01:40:02
以前,我遇到了JSF2.0页面不能完全呈现的问题。然而,我在我的config-faces.xml中发现了我的愚蠢之处,我使用:
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
...
</faces-config>而不是:
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
...
</faces-config> 当不小心使用复制粘贴机制时出现的问题。
https://stackoverflow.com/questions/25345518
复制相似问题