Hibernate 无法达到的目标';客户';返回空值

Hibernate 无法达到的目标';客户';返回空值,hibernate,jsf,Hibernate,Jsf,我创建了一个要添加的方法,我使用了jsf和hibarnate框架,但出现了一个明显的异常,她阻止了我 这是我的课 package controller; import java.io.Serializable; import javax.faces.bean.RequestScoped; import org.springframework.beans.factory.annotation.Autowired; import model.Client; import javax.faces.

我创建了一个要添加的方法,我使用了jsf和hibarnate框架,但出现了一个明显的异常,她阻止了我

这是我的课

package controller;

import java.io.Serializable;
import javax.faces.bean.RequestScoped; 
import org.springframework.beans.factory.annotation.Autowired;
import model.Client;
import javax.faces.bean.ManagedBean;
import service.ClientService;

@ManagedBean(name="clientBean")
@RequestScoped
public class ClientBeanManger implements Serializable {

    private static final long serialVersionUID = 1L;
    private static final String SUCCESS = "success";
    private static final String ERROR   = "error";

    //Spring User Service is injected...
    @Autowired
    ClientService clientService;
    private Client client;




    public Client getClient() {
        return client;
    }


    public void setClient(Client client) {
        this.client = client;
    }


    public ClientBeanManger() {

    }

    private int idClient;
    private String nomClient;
    private String adresseClient;
    private String telephoneClient;
    private String mailClient; 



    // Add client @return String - Response Message

    public void addClient(Client client) {
        client.setIdClient(idClient);
        client.setNomClient(nomClient);
        client.setAdresseClient(adresseClient);
        client.setTelephoneClient(telephoneClient);
        client.setMailClient(mailClient);
        clientService.add(client);          
    }


    //Getter and  setter 
    public ClientService getClientService() {
        return clientService;
    }

    public void setClientService(ClientService clientService) {
        this.clientService = clientService;
    }

    public int getIdClient() {
        return idClient;
    }

    public void setIdClient(int idClient) {
        this.idClient = idClient;
    }

    public String getNomClient() {
        return nomClient;
    }

    public void setNomClient(String nomClient) {
        this.nomClient = nomClient;
    }

    public String getAdresseClient() {
        return adresseClient;
    }

    public void setAdresseClient(String adresseClient) {
        this.adresseClient = adresseClient;
    }

    public String getTelephoneClient() {
        return telephoneClient;
    }

    public void setTelephoneClient(String telephoneClient) {
        this.telephoneClient = telephoneClient;
    }

    public String getMailClient() {
        return mailClient;
    }

    public void setMailClient(String mailClient) {
        this.mailClient = mailClient;
    }


}
她是我的看法

 <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
         xmlns:p="http://primefaces.org/ui">
     <h:body>
         <h:form  action="" method="post">
          <table border="1">
           <tr>
            <td><h:outputLabel value="Id :"/></td>
            <td><h:inputText id="id" value="#{clientBean.idClient}"/>  
            </td>
           </tr>
           <tr>
            <td><h:outputLabel for="name" value="Name :" /></td>
            <td><h:inputText id="name" value="#{clientBean.nomClient}"/>

            </td>
           </tr>
            <tr>
            <td><h:outputLabel for="adresse" value="Adresse :" /></td>
            <td><h:inputText id="adresse" value="#{clientBean.adresseClient}"/>
            </td>
           </tr>
            <tr>
            <td><h:outputLabel for="telephone" value="Telephone :" /></td>
            <td><h:inputText id="telephone" value="#{clientBean.telephoneClient}"/>
           </td>
           </tr>
              <tr>
            <td><h:outputLabel for="mail" value="Mail :" /></td>
            <td><h:inputText id="mail" value="#{clientBean.mailClient}"/>
           </td>
           </tr>
             <tr>
           <td><h:commandButton id="addclient" value="Add" action="#{clientBean.addClient}"/></td>
            <td><h:commandButton id="reset" value="Lister"  action="Submit"/></td> 
           </tr>
          </table>
         </h:form>
    </h:body>
    </html>

我知道还有很多问题都是相同的,但是没有一个有效。请帮我一个忙,我开始放开我自己。

@AutoWired
不会将spring bean注入jsf bean;它们处于两种不同的环境中

只有当
客户端BeanManger
也是Spring MVC管理的bean时,Spring才能使用
@Autowired
注入bean。从您的问题的编写方式和评论来看,我认为您需要探索连接Springbean和JSFbean的基础知识

请看以下内容


当错误发生时,在页面加载或提交表单上?尝试实例化属性
客户端
@Omar:在那里可以实例化对象client@user3766709,您在上面的托管bean中定义它的位置,即
privateclient=newclient()Etat HTTP 500 - javax.el.PropertyNotFoundException: /pages/index.xhtml @35,97 action="#{clientBean.client.addClient}": Target Unreachable, 'client' returned null