日期:2014-05-17 浏览次数:20784 次
//spring配置文件
<bean id="LoginAction" class="com.action.LoginAction" scope="prototype">
<property name="service" ref="LoginService"></property>
</bean>
<bean id="LoginService" class="com.service.impl.LoginServiceImpl">
<property name="dao" ref="UserDao"></property>
</bean>
<bean id ="UserDao" class="com.dao.impl.UserDaoImpl" >
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
//service文件
private UserDao dao;
public void setDao(UserDao dao) {
this.dao = dao;
}
public boolean checkEmail(String s) {
int num = dao.checkEmail(s);
return num==0?true:false;
}
//dao文件
public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
public int checkEmail(String s) {
String hql="frome User where email = ?";
List<User> list =this.getHibernateTemplate().find(hql,s);
return list.size();
}
}
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">你这样试试
<constructor-arg ref="myDataSource"></constructor-arg>
</bean>
<bean id="aDao" class="com.defonds.jdbc.test.dao.ADaoImpl">
<property name="jdbcTemplate">
<ref bean="jdbcTemplate"/>
</property>
</bean>