菜鸟求教SSH2登录例子问题
//实现类 loginDaoImpl
public class loginDaoImpl extends HibernateDaoSupport implements loginDao{
public int loginSelect(String name, String Password) {
List list = this.getHibernateTemplate().find("from Photouser t where t.username=? and t.password=?",name,Password);
System.out.println(list);
if(list.size()==1){
return 1;
}
return 0;
}
}
//Service类 loginServiceImpl
public class loginServiceImpl implements loginService{
private loginDao logindao;
public loginDao getLogindao() {
return logindao;
}
public void setLogindao(loginDao logindao) {
this.logindao = logindao;
}
public int loginSelect(String name, String Password) {
System.out.println("========Service========");
int row = this.logindao.loginSelect(name, Password);
return row;
}
}
//Action类
public class loginAction extends ActionSupport{
private loginService service;
private loginDao logindao;
public loginDao getLogindao() {
return logindao;
}
public void setLogindao(loginDao logindao) {
this.logindao = logindao;
}
public loginService getService() {
return service;
}
public void setService(loginService service) {
this.service = service;
}
public String execute() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
System.out.println(logindao);
String name = request.getParameter("username");
String Password = request.getParameter("password");
int row = this.logindao.loginSelect(name, Password); //此处logindao老是为空,所以我没办法调用Service层接口,我想应该是没注入,找了好久,觉得配置没什么问题呀!麻烦各位帮我找找问题,万分感谢。
System.out.println(row);
return SUCCESS;
}
}
Spring 的配置文件
<bean id="transactionManeger" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- -->
<bean id="loginDao" class="com.dao.impl.loginDaoImpl" scope="singleton">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="loginServiceTarget" class="com.service.impl.loginServiceImpl" scope="singleton">
<property name="logindao" ref="loginDao"/>
</bean>
<bean id="loginService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target" ref="loginServiceTarget"/>
<property name="transactionManager" ref="transactionManeger"/>
<property name="transactionAttributes">
<props>
<!-- <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> -->
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>