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 方法。