使用@AutoWired替换struts2 Action中的get、set方法

来源:互联网 发布:免费海关数据 米课 编辑:程序博客网 时间:2024/05/17 14:14

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不理解

0 0
原创粉丝点击