日期:2014-05-19  浏览次数:20715 次

spring依赖注入问题
这是类代码:
public class FoodAction extends ActionSupport {
private FoodBiz fb;
public String execute()throws Exception{
List<Food> foods=getFb().getAllFood();
for (int i = 0; i < foods.size(); i++) {
System.out.println(foods.get(i).getName());
}
return SUCCESS;
}
public void setFb(FoodBiz fb) {
this.fb = fb;
}
public FoodBiz getFb() {
return fb;
}
部分配置文件:
<!-- biz -->
<bean id="FoodBiz" class="biz.impl.FoodBizImpl">
<property name="fd">
<ref bean="FoodDao" />
</property>
</bean>
<!-- action -->
<bean name="food" class="action.FoodAction">
<property name="fb">
<ref bean="FoodBiz"/>
</property>
</bean>
fb为null

------解决方案--------------------
检查下有没有struts和spring集成的jar
------解决方案--------------------
简单的测试,你就不能认真点吗!