0
我是JSF和JSF的新手標籤在我的First.xhtml中無法正常工作。 我的web.xml文件中有如下代碼JSF標記未呈現爲HTML
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>JSFNewProject</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
代碼在我faces.config文件
<?xml version="1.0" encoding="UTF-8"?>
<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>
My code in the First.xhtml is
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<title>Facelet</title>
<h:body>
<h2>hi Amit</h2>
<h:form>
<h:outputLabel id="firstNameOutputId" value="firstname:" />
<h:inputText id="firstNameInputId" value="#{userRegistration.firstName}"> </h:inputText>
<h:outputLabel id="lastNameOutputId" value="lastname:" />
<h:inputText id="lastNameInputId" value="#{userRegistration.lastName}"> </h:inputText>
<h:outputLabel id="ageOutputId" value="Age" />
<h:inputText id="ageInputId" value="#{userRegistration.age}"> </h:inputText>
<h:outputLabel id="dobOutputId" value="DoB" />
<h:inputText id="dobInputId" value="#{userRegistration.dob}"> </h:inputText>
<h:outputLabel id="cityOutputId" value="City" />
<h:inputText id="cityInputId" value="#{userRegistration.city}"> </h:inputText>
<h:outputLabel id="salaryOutputId" value="Salary" />
<h:inputText id="salaryInputId" value="#{userRegistration.salary}"> </h:inputText>
<h:commandButton id="userRegistrationCmdBtnId" value="Register" action="userRegistration.processRegistration">
</h:commandButton>
</h:form>
</h:body>
</html>
我已經嘗試了像改變URL映射爲/ faces/*並且包含罐許多選項在WEB-INF/lib下,但都沒用...... 幫助正在徵求....謝謝