日期:2014-05-18 浏览次数:20708 次
package action;
import service.Regiestservice;
import domain.Users;
public class regiest {
private Users users;
private Regiestservice regiestserviceimpl;
public Users getUsers() {
return users;
}
public void setUsers(Users users) {
this.users = users;
}
public void setRegiestserviceimpl(Regiestservice regiestserviceimpl) {
this.regiestserviceimpl = regiestserviceimpl;
}
public String regiestaction()
{
System.out.println(regiestserviceimpl);
return "success";
}
}
package daoimpl;
import java.util.List;
import java.util.Set;
import org.hibernate.LockMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import dao.UsersDAO;
import domain.Users;
public class UsersDAOimpl extends HibernateDaoSupport implements UsersDAO {
private static final Logger log = LoggerFactory.getLogger(UsersDAOimpl.class);
protected void initDao() { }
public void save(Users transientInstance) {
log.debug("saving Users instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public static UsersDAO getFromApplicationContext(ApplicationContext ctx) {
return (UsersDAO) ctx.getBean("UsersDAO");
}
}
package serviceimpl;
import service.Regiestservice;
import dao.UsersDAO;
import daoimpl.UsersDAOimpl;
import domain.Users;
public class Regiestserviceimpl implements Regiestservice {
private UsersDAO usersDAO;
public UsersDAO getUsersDAO() {
return usersDAO;
}
public void setUsersDAO(UsersDAO usersDAO) {
this.usersDAO = usersDAO;
}
public boolean regiest(Users user)
{
usersDAO.save(user);
return true;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-insta