使用@AutoWired替換struts2 Action中的get、set方法
阿新 • • 發佈:2019-02-17
public class LoginAction{
@Autowired
private ILoginDao loginDao;
@Autowired
private IReportDao reportDao;
......
}
spring applicationContext.xml
<!-- 註解掃描包 -->
<context:component-scan base-package="cn.XXX.ation" />
<bean id="loginDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="cn.XXX.dao.ILoginDao"/>
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
<bean id="reportDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="cn.XXX.dao.IReportDao"/>
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
<bean id="loginAction" class="cn.XXX.action.LoginAction"/>
關於dao的bean配置可以理解,但是action也需配置bean不理解