2 回答
TA贡献1850条经验 获得超11个赞
给你一段我的代码
package com.s2sh.dao.impl;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.s2sh.dao.UserDao;
import com.s2sh.mobel.User;
public class UserDaoImpl extends HibernateDaoSupport implements UserDao{
//用户登录
public User findUser(User user) {
try{
String hql="from User where name=? and password=?";
List list = (List) this.getHibernateTemplate().find(hql,new String[]{user.getName(),user.getPassword()});
if(list.size()>=1){
return (User)list.get(0);
}else {
return null;
}
}catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
添加回答
举报