1 增加SSH支持
2编写VO BO DAO IDAO 包,
3 DAO继承HibernateDaoSupport 实现IDAO
并且用到HibernateTemplate模板。HibernateDaoSupport有个属性sessionFactory
4 在applicationContext.xml中注册DAO,
<bean id="loginDao" class="com.dao. LoginDao">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
在applicationContext.xml中注册action,
<bean name="/login" class="com.struts.action.LoginAction">
<property name="loginDaoImpl">
<ref local="loginDaoImpl"/>
</property>
</bean>
5 struts-config.xml管理action的任务交给applicationContext.xml管理
将struts-config.xml中action的type 的值改为:
type="org.springframework.web.struts.DelegatingActionProxy"
并且在struts-config.xml增加一个插件,让struts-config.xml认识到
applicationContext.xml
插件如下:
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml" />
</plug-in>
6在 action中创建一个接口对象,并且设定get set 方法。
本文介绍如何在项目中整合Spring框架与Struts框架,包括使用Hibernate进行数据访问层的开发,Spring管理业务层组件,以及Struts处理用户请求。通过具体步骤说明了配置文件的设置、DAO层的实现方式及Action与DAO之间的依赖注入。
9万+

被折叠的 条评论
为什么被折叠?



