关于spring的空指针异常

这是我的applicationContext.xml的配置;
<bean id="themeDao" class="com.sc.dao.imp.ThemeDAO"></bean>
<bean id="themeService" class="com.sc.service.ThemeService">
<property name="themeDao" ref="themeDao"></property>
</bean>
<bean id="themeAction" class="com.sc.web.action.ThemeAction">
<property name="themeService" ref="themeService"></property>
</bean>

我的访问的ThemeAction大致代码如下:

public class ThemeAction extends ActionSupport {
private ThemeService themeService;

public ThemeService getThemeService() {
return themeService;
}

public void setThemeService(ThemeService themeService) {
this.themeService = themeService;
}



public String find() {
System.out.println(getThemeService() + "000000000000000");
//themes = themeService.findAll();
return NONE;
}
}


结果一访问这个action,发现themeService为null,它不是应该被spring自动注入的吗?

猜你喜欢

转载自1334929701-qq-com.iteye.com/blog/1836262