2017-11-24 24 views
0

저는 JSF를 처음 사용하면서 문제가 있습니다. 나는 <h:inputText> 태그를 포함하는 작은 응용 프로그램을 개발했습니다. 응용 프로그램을 실행할 때 텍스트 입력 부분이 표시되지 않습니다.JSF 태그 <h:inputText>이 작동하지 않습니다.

User.java : (Bean을 관리)

package com.JSF.UIExample; 

import javax.faces.bean.ManagedBean; 
import javax.faces.bean.RequestScoped; 

@ManagedBean(name = "user", eager = true) 
@RequestScoped 
public class User { 
    private String name; 
    private String password; 
    private String email; 
    private String gender; 
    private String address; 

    public User(){ } 
    // getter and setter 
} 

Detail.xhtml :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:h="http://xmlns.jcp.org/jsf/html" 
xmlns:f="http://xmlns.jcp.org/jsf/core"> 

<h:head> 
    <title>User Registration</title> 
</h:head> 

<h:body> 
    <h:form id="form"> 
     <table> 
      <tr> 
       <td><h:outputLabel for="username"><b>Username:</b></h:outputLabel></td> 
       <td><h:inputText id="name-id" value="#{user.name}" /></td> 
      </tr> 
      <tr> 
       <td><h:outputLabel for="password"><b>Password:</b></h:outputLabel></td> 
       <td><h:inputSecret id="password-id" value="#{user.password}" /></td> 
      </tr> 
      <tr> 
       <td><h:outputLabel for="email">Email:</h:outputLabel></td> 
       <td><h:inputText id="email-id" value="#{user.email}" /></td> 
      </tr> 
      <tr> 
       <td><h:outputLabel for="gender">Gender:</h:outputLabel></td> 
       <td><h:selectOneRadio value="#{user.gender}"> 
         <f:selectItem itemValue="Male" itemLabel="Male" /> 
         <f:selectItem itemValue="Female" itemLabel="Female" /> 
        </h:selectOneRadio></td> 
      </tr> 
      <tr> 
       <td><h:outputLabel for="address">Address:</h:outputLabel></td> 
       <td><h:inputText id="address-id" value="#{user.address}" cols = "50" rows = "5" /></td> 
      </tr> 
     </table> 
     <h:commandButton value = "Submit" action = "Response.xhtml"></h:commandButton> 
    </h:form> 
</h:body> 
</html> 

Response.xhtml을 (사용자 등록의 세부 사항을 작성) :

다음 코드입니다
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://xmlns.jcp.org/jsf/html" 
    xmlns:f="http://xmlns.jcp.org/jsf/core"> 

<h:head> 
    <title>User Details</title> 
</h:head> 

<h:body> 
    <h2> 
     <h:outputText value="Hello #{user.name}" /> 
    </h2> 
    <h4>You have been registered successfully. Following are your 
     details</h4> 
    <table> 
     <tr> 
     <td><b>Email:</b></td> 
     <td><h:outputText value = "#{user.email}"/></td> 
     </tr> 
     <tr> 
     <td><b>Gender:</b></td> 
     <td><h:outputText value = "#{user.gender}"/></td> 
     </tr> 
     <tr> 
     <td><b>Address:</b></td> 
     <td><h:outputText value = "#{user.address}"/></td> 
     </tr> 
    </table> 
</h:body> 

web.xml :

<?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"> 

    <welcome-file-list> 
     <welcome-file>faces/Detail.xhtml</welcome-file> 
    </welcome-file-list> 

    <!-- 
     FacesServlet is main servlet responsible to handle all request. 
     It acts as central controller. 
     This servlet initializes the JSF components before the JSP is displayed. 
    --> 

    <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>/faces/*</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>*.jsf</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>*.faces</url-pattern> 
    </servlet-mapping> 

    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>*.xhtml</url-pattern> 
    </servlet-mapping> 

</web-app> 

메이븐 의존성 :

 <dependency> 
      <groupId>com.sun.faces</groupId> 
      <artifactId>jsf-api</artifactId> 
      <version>2.1.7</version> 
     </dependency> 

     <dependency> 
      <groupId>com.sun.faces</groupId> 
      <artifactId>jsf-impl</artifactId> 
      <version>2.1.7</version> 
     </dependency> 

의 xmlns 모두 XHTML 파일에서 : 시간은 = "http://xmlns.jcp.org/jsf/html는"는 경고를 찾을 수 없습니다 보여줍니다 URI http://xmlns.jcp.org/jsf/html & 의 xmlns에 대한 facelet 태그 라이브러리는 : F = "http://xmlns.jcp.org/jsf/core는" 경고 누군가가 내가 갈거야 어디 말할 수 URI http://xmlns.jcp.org/ 에 대한 facelet 태그 라이브러리를 찾을 수 없습니다 보여줍니다 잘못된.

답변

0
+0

답장을 보내 주셔서 감사 많이. 이전 네임 스페이스로 변경되었으며 나에게 잘 작동했습니다. –

+0

나는 당신의 대답을 유용하다고 표시하게되어 기쁘 겠지만 같은 것을하기에 충분한 평판이 없다. –

+1

좋은 것으로 표시했습니다. –