注入的方式
方式一
private TestService testService;
public void setTestService(TestService testService){
this.testService=testService;
}
在Spring中配置
<bean id="testAction class="zj.hz.zjcitech.testAction">
<property name="testService" ref="对应注入的ID名称"></property>
</bean>
方式二
private TestService testService;
@resource --根据set后面的匹配小写
public void setTestService(TestService testService){
this.testService=testService;
}
方式三
@resource ----根据testService来匹配
private TestService testService;
方式二与方式三都要在配置中扫描包。