hibernate登录验证
hibernate在进行登录验证时,怎么返回验证结果是否合格。烦请各位专家帮忙解决一下。String username=LM.toChinese(request.getParameter("name"));
String password=request.getParameter("pwd");
SessionFactory sf=new Configuration().configure().buildSessionFactory();
Session session=sf.openSession();
Transaction ts=session.beginTransaction();
String hql="from User where Username=? and userpassword=?";
List<User> list=session.createQuery(hql).setString(0, username).setString(1, password).list();
/*一直返回登录成功,原因知道但是为什么不跳转到Register.jsp*/
if(list==null||list.equals("")){
request.getRequestDispatcher("login.html").forward(request, response);
System.out.println("登录失败");
}else{
request.getRequestDispatcher("Register.jsp").forward(request, response);
System.out.println("登录成功");
}
session.getTransaction().commit();
session.close();
sf.close();