在xhtml文件中找不到Hibernate属性错误

时间:2016-01-18 09:32:30

标签: java hibernate

这是我的课程我试图保留数据

 import javax.annotation.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.hibernate.Session;

@ManagedBean
@SessionScoped
public class Data {
    private Members m;
    private  HibernateUtil help;
    private Session session ;

     public void addUser(){
         m = new Members("SumanthJois");
      session = HibernateUtil.getSessionFactory().openSession();
      session.beginTransaction();
      session.save(m);
      session.getTransaction().commit();
      session.close();
     }


}

这是我的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://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>

            <h:commandButton value="Add User" action="#{data.addUser()}"/>

        </h:form>
    </h:body>
</html>

有人请教如何使用xhtml调用函数?我的代码怎么了?

0 个答案:

没有答案