我明明DAO有方法 ,Spring 也注入了, 页面老报500 显示Action中调用的底层方法为空 ... 求解?  Spring.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml">
</property>
</bean>
<!-- Dao -->
<bean id="StudentInfoDAO" class="com.Sy.Dao.StudentInfoDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="LoginInfoDAO" class="com.Sy.Dao.LoginInfoDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- Biz -->
<bean id="loginBiz" class="com.Sy.Biz.LoginBizImpl">
<property name="logDao">
  <ref bean="LoginInfoDAO"/>
</property>
</bean>
<bean id="stubiz" class="com.Sy.Biz.StudentBizImpl">
<property name="stuDao">
<ref bean="StudentInfoDAO" />
</property>
</bean>
    <!-- Action -->
    <bean name="login" class="com.Sy.Action.LoginAction">
      <property name="logbiz" ref="loginBiz"></property>
    </bean>
    <bean name="stu" class="com.Sy.Action.StuinfoAction">
      <property name="stuBiz" ref="stubiz"></property>
    </bean>
    
</beans>Action::public class LoginAction extends ActionSupport { private LoginBiz logbiz; public void setLogbiz(LoginBiz logbiz) {
this.logbiz = logbiz;
} private LoginInfo logInfo = new LoginInfo(); public LoginInfo getLogInfo() {
return logInfo;
} public void setLogInfo(LoginInfo logInfo) {
this.logInfo = logInfo;
} public String execute() { List list = logbiz.findByExample(logInfo);    -显示此方法为空 if (list.size() > 0 && list != null) {
return SUCCESS; }
return ERROR;
}}
-  BIZ 业务逻辑层
import java.util.List;import com.Sy.Dao.LoginDao;
import com.Sy.Entity.LoginInfo;public class LoginBizImpl implements LoginBiz { private LoginDao logDao; public void setLogDao(LoginDao logDao) {
logDao = logDao;
} public void save(LoginInfo transientInstance) {
logDao.save(transientInstance);
} public List findByExample(LoginInfo instance) {
return logDao.findByExample(instance); }
--DAO层
public List findByExample(LoginInfo instance) {
log.debug("finding LoginInfo instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}

解决方案 »

  1.   

      是说我Action中调用的 Biz方法为空 、。 
      

  2.   

    <bean id="LoginInfoDAO" class="com.Sy.Dao.LoginInfoDAO">com.Sy.Dao.LoginInfoDAO"这个是LoginInfoDAO 实现类么?
    你上面好几个都是这样
      

  3.   

    <bean id="StudentInfoDAO" class="com.Sy.Dao.StudentInfoDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>你这样写是不对的 这样你的DAO没有什么用  肯定是空了你在DAO层再定义一个DAOImp层应该可以了 ,就像你的业务实现层一样
      

  4.   

      各位,我的这个类 com.Sy.Dao.StudentInfoDAO, 本来就是用Hibernate逆向工程 、  直接生成的。   然后再这个实现类里抽出它的接口、 各位应该懂吧 。 生成的实现类本来就是这个命名 StudentInfoDAO   。  这个问题我已经解决了  。  是我没有在配置struts2-spring-plugin-2.1.6.jar 、 还没有在struts.xml中配置这句<constant name="struts.objectFactory" value="spring"/> 造成的。