新手求解登录问题,struts+hibernate的
在userdao类下,写个函数,用来判断登录用户的。
public boolean check(String name,String password) { SessionFactory sessionFactory = HibernateSessionFactory .getSessionFactory(); Session session = sessionFactory.openSession(); //Transaction transaction=session.beginTransaction(); String hql1 = "from Hr_User hrUser where hrUser.username=? and hrUser.userpassword=?"; Query query = session.createQuery(hql1).setString(0, name).setString(1, password); List<Hr_User> list = query.list(); if (list.size() > 0) { session.close(); return true; } else { session.close(); return false; } } public String hr_userLogin() { bool=hrUserDAO.check(name,password); if(bool==true){ return SUCCESS; } else { return INPUT; } }