public boolean isExit(User user) {
Session ss=HibernateSessionFactory.getSession();
String hql="from User where username='"+user.getUsername()+"' and password='"+user.getPassword()+"' and identity='"+user.getIdentity()+"'";
try{
Query query=ss.createQuery(hql);
int s=query.list().size();
if(s==0){
return false;
}
}catch(Exception e){
e.printStackTrace();
}
ss.close();
return true;
}
在Action调用该方法,之前hql语句仅有username和password验证,跳转至正确的页面,添加identity(数据类型是中文字符的)验证后就跳转到错误的页面了,跪求原因!!!
Session ss=HibernateSessionFactory.getSession();
String hql="from User where username='"+user.getUsername()+"' and password='"+user.getPassword()+"' and identity='"+user.getIdentity()+"'";
try{
Query query=ss.createQuery(hql);
int s=query.list().size();
if(s==0){
return false;
}
}catch(Exception e){
e.printStackTrace();
}
ss.close();
return true;
}
在Action调用该方法,之前hql语句仅有username和password验证,跳转至正确的页面,添加identity(数据类型是中文字符的)验证后就跳转到错误的页面了,跪求原因!!!
数据库有满足这个条件的数据吗?否则query.list()是null,query.list().size()会出错啊