Java JSF错误类不具有该属性

Java JSF错误类不具有该属性,java,mysql,jsf,jpa,Java,Mysql,Jsf,Jpa,我正在尝试向JSF表中添加一些mysql表列。我得到了一个错误: /index.xhtml:类“logon.User”没有属性“description”。 请帮忙 User.java package logon; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Generation

我正在尝试向JSF表中添加一些mysql表列。我得到了一个错误:

/index.xhtml:类“logon.User”没有属性“description”。 请帮忙

User.java

package logon;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="users")
public class User {

    private int id;
    public String name = null;
    public String surname = null;
    public String username = null;
    public String description = null;
    public String email = null;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getId(){
        return id;
    }
    public void setId(int id){
        this.id = id;
    }

    @Column(name = "Name")
    public String getName(){
        return name;
    }

    public void setName(String Name){
        this.name = Name;
    }

    @Column(name = "Surname")
    public String getSurname(){
        return surname;
    }

    public void setSurname(String Surname){
        this.surname = Surname;
    }

    @Column(name = "Username")
    public String getUsername(){
        return username;
    }
    public void setUsername(String Username){
        this.username = Username;
    }
    @Column(name = "Description")
    public String getDescription(){
        return description;
    }

    public void setDescription(String Description){
        this.description = Description;
    }

}
LogonTest.java

package logon;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.persistence.Query;


@ViewScoped
@SessionScoped
@javax.faces.bean.ManagedBean(name = "logonTest")
public class LogonTest implements Serializable {
    @PersistenceUnit(unitName = "Webbeans_RESOURCE_LOCAL")
    private EntityManagerFactory emf;

    public List<User> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        this.userList = userList;
    }

    public List<User> userList = new ArrayList();


    @PostConstruct
    public void init() {
        EntityManager em = emf.createEntityManager();
        // Read the existing entries and write to console
        Query q = em.createQuery("SELECT u FROM User u");
        userList = q.getResultList();
        System.out.println("Size: " + userList.size());
    }

    public LogonTest() {

    }

}
index.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!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://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
        >
<h:head>
    <title>index.xhtml</title>
</h:head>

<h:body>

    <h1>JSF 2.0 View Data From The Database Table Example</h1>

    <h:dataTable value="#{logonTest.userList}" var="u" border="1">


        <h:column>
            <f:facet name="header">
                ID
            </f:facet>
            #{u.id}
        </h:column>

        <h:column>
            <f:facet name="header">
                Name
            </f:facet>
            #{u.username}
        </h:column>

        <h:column>
            <f:facet name="header">
                Surname
            </f:facet>
            #{u.surname}
        </h:column>

        <h:column>
            <f:facet name="header">
                Name
            </f:facet>
            #{u.name}
        </h:column>

        <h:column>
            <f:facet name="header">
                Description
            </f:facet>
            #{u.description}
        </h:column>

    </h:dataTable>

</h:body>

</html>

你确定你在运行你认为正在运行的代码?例如,如果你看到用户实际上有一个描述吗?当你从视图中完全删除包含描述的最后一列时,你得到了什么?编辑:另外,你的托管bean不能同时是视图范围和会话范围