hibernate验证用户登录时用户名和密码 5
用hibernate验证用户名和密码,在adminDAOImpl中总会提示找不到criteria这个类,但是明明导入了。上图,有代码,错误信息。求高人指点。publicc...
用hibernate验证用户名和密码,在adminDAOImpl中总会提示找不到criteria这个类,但是明明导入了。上图,有代码,错误信息。求高人指点。
public class AdminLogIn extends ActionSupport {
private Admin adminBean;
//private AdminDAOImpl ad = new AdminDAOImpl();
public Admin getAdminBean() {
return adminBean;
}
public void setAdminBean(Admin adminBean) {
this.adminBean = adminBean;
}
public String execute() {
AdminDAOImpl ad = new AdminDAOImpl();
if(ad.isValidAdmin(adminBean.getAdminName(), adminBean.getAdminPassword()))
return SUCCESS;
else
{
adminBean.setAdminName("");
adminBean.setAdminPassword("");
return ERROR;
}
}
}
public class AdminDAOImpl implements AdminDAO {
public AdminDAOImpl() {};
public boolean isValidAdmin(String adminName, String adminPassword) {
Session s = null;
Admin admin;
try {
s = HibernateUtil.getSessionFactory().getCurrentSession();
Criteria c = s.createCriteria(Admin.class);
c.add(Restrictions.eq("adminName", "bochao"));
admin =(Admin) c.uniqueResult();
} finally {
if (s != null)
s.close();
}
if(admin == null)
return true;
else
return false;
}
}
错误信息
Struts Problem Report
Struts has detected an unhandled exception:
Messages:org.hibernate.criterion.Criterion org/hibernate/criterion/Criterion File:org/apache/catalina/loader/WebappClassLoader.javaLine number:1,711 展开
public class AdminLogIn extends ActionSupport {
private Admin adminBean;
//private AdminDAOImpl ad = new AdminDAOImpl();
public Admin getAdminBean() {
return adminBean;
}
public void setAdminBean(Admin adminBean) {
this.adminBean = adminBean;
}
public String execute() {
AdminDAOImpl ad = new AdminDAOImpl();
if(ad.isValidAdmin(adminBean.getAdminName(), adminBean.getAdminPassword()))
return SUCCESS;
else
{
adminBean.setAdminName("");
adminBean.setAdminPassword("");
return ERROR;
}
}
}
public class AdminDAOImpl implements AdminDAO {
public AdminDAOImpl() {};
public boolean isValidAdmin(String adminName, String adminPassword) {
Session s = null;
Admin admin;
try {
s = HibernateUtil.getSessionFactory().getCurrentSession();
Criteria c = s.createCriteria(Admin.class);
c.add(Restrictions.eq("adminName", "bochao"));
admin =(Admin) c.uniqueResult();
} finally {
if (s != null)
s.close();
}
if(admin == null)
return true;
else
return false;
}
}
错误信息
Struts Problem Report
Struts has detected an unhandled exception:
Messages:org.hibernate.criterion.Criterion org/hibernate/criterion/Criterion File:org/apache/catalina/loader/WebappClassLoader.javaLine number:1,711 展开
2个回答
展开全部
admin =(Admin)s.createCriteria(Admin.class).add(Restrictions.eq("adminName","bochao")).uniqueResult();先这样写吧,你的错误信息太少了。多贴点信息上来吧。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询