1,<wbr></wbr><wbr></wbr>在Struts<wbr></wbr>中所有的jsp<wbr></wbr>文件本来是有Action<wbr></wbr>自己进行管理和处理的。现在由Spring<wbr></wbr>进行管理,但是处理还是仍然靠自己里面的Action<wbr></wbr>进行处理。所以在Struts-config.xml<wbr></wbr>中必须设置它的监听类,<wbr></wbr><controller<wbr></wbr><wbr></wbr>processorClass="org.springframework.web.struts.DelegatingRequestProcessor"><wbr></wbr><wbr></wbr></controller><wbr></wbr>2,<wbr></wbr><wbr></wbr>因为现在由Spring<wbr></wbr>进行管理所有的Action,<wbr></wbr>所有的Action<wbr></wbr>在Srping <wbr></wbr>就应该进行初始化<wbr></wbr><bean name="/login" class="com.yxj.oa.login.LoginAction"><wbr></wbr> <property name="loginDao"><wbr></wbr><ref local="LoginDao"/><wbr></wbr> </property><wbr></wbr>
</bean>
3,由以上两点可以得出,Struts-config.xml中必须加载Spring的applicationContext.xml<wbr></wbr><!--加载applicationContext.xml-->
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>
4,HibernateTemplate的配置:<wbr></wbr><!--<wbr></wbr>把连接池放在这里配置,<wbr></wbr>便于移植,最后这个配置会移到spring配置文件中去--><wbr></wbr> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><wbr></wbr><property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"></property><wbr></wbr><property name="url" value="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=officAuto"></property><wbr></wbr><property name="username" value="sa"></property><wbr></wbr><property name="password" value="123"></property><wbr></wbr> </bean><wbr></wbr> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><wbr></wbr><property name="dataSource"><wbr></wbr> <ref local="dataSource"/><wbr></wbr></property><wbr></wbr><property name="hibernateProperties"><wbr></wbr> <props><wbr></wbr><prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop><wbr></wbr><prop key="hibernate.show_sql">true</prop><wbr></wbr> </props><wbr></wbr></property><wbr></wbr><property name="mappingResources"><wbr></wbr> <list><wbr></wbr><value>com/yxj/oa/usermanage/Userinfo.hbm.xml</value><wbr></wbr> </list><wbr></wbr></property><wbr></wbr> </bean><wbr></wbr><bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"><wbr></wbr><property name="sessionFactory"><wbr></wbr> <ref local="sessionFactory"/><wbr></wbr></property><wbr></wbr> </bean><wbr></wbr>5,<wbr></wbr>所以在dao<wbr></wbr>中只需要这样调用下就可以了
<bean id="UserDao" class="com.yxj.oa.usermanage.UserDao"><wbr></wbr> <property name="hibernateTemplate"><wbr></wbr><ref local="hibernateTemplate"/><wbr></wbr> </property><wbr></wbr></bean><wbr></wbr>6,在dao中要去继承import org.springframework.orm.hibernate3.support.HibernateDaoSupport;<wbr></wbr>HibernateDaoSupport<wbr></wbr>
<wbr></wbr>
分享到:
相关推荐
通过简单的实例来说明SSH(Struts+Spring+Hibernate)的结合,让你对SSH有一个充分的了解。
语言程序设计资料:基于SSH(Struts + Spring + Hibernate)框架的网上购物系统.ppt
SSH(struts+spring+hibernate)面试题总结
由于本代码软件lib文件夹过于大 所以本人把lib文件夹删除 如果由朋友需要在后面我会给出,加上lib文件夹 就可以直接运行。
SSH集成 Struts+spring+hibernate集成SSH集成 Struts+spring+hibernate集成
SSH(Struts Spring Hibernate)Java三大框架的整合。
Java-Spring+Struts+Hibernate-SSH框架整合01-Spring+Hibernate(一步一步的教你敲代码)(博客园,博客名称:Java-Spring+Struts+Hibernate-SSH框架整合01-Spring+Hibernate)
共分四个压缩包,JavaEE企业应用实战-Struts2+Spring3+Hibernate整合开发(第3版).part3
基于struts+spring+hibernate+oracle的移动ssh项目源码 基于struts+spring+hibernate+oracle的移动ssh项目源码 基于struts+spring+hibernate+oracle的移动ssh项目源码 基于struts+spring+hibernate+oracle的移动ssh...
移动ssh项目(struts+spring+hibernate+oracle)10毕业设计—(包含完整源码可运行).rar
SSH2框架搭建所需jar包,版本:struts-2.3.14+spring-2.5.6+hibernate3.6.10
MyEclipse开发SSH(Struts+Spring+Hibernate)入门 超级详细,不下载后悔~!!!
SSH(struts+spring+hibernate)迅速开发,很详细啊
MyEclipse开发SSH(Struts+Spring+Hibernate)
Struts 2.3.25 + spring-4.2.2 + hibernate-5.0.2 Apache Struts Struts 2.3.24.1 has been released on 24 september 2015. http://struts.apache.org/download.cgi#struts23241 spring-framework-4.2.2.RELEASE-...
简单的ssh项目,泛型BaseAction配置,简单注解配置,applicationContext.xml配置,jar包地址 链接:https://pan.baidu.com/s/14NkywuhG6mESyhE1VMkhOQ 密码:en19
项目原型:Struts2.3.16 + Spring4.1.1 + Hibernate4.3.6 二、 项目目的: 整合使用最新版本的三大框架(即Struts2、Spring4和Hibernate4),搭建项目架构原型。 项目架构原型:Struts2.3.16 + Spring4.1.1 + ...
SSH - Struts2 + Spring4 + Hibernate4 + c3p0 + Mysql.rar
本文并不想介绍Struts,Spring,Hibernate的原理系统架构等,本文地目的是通过一个较复杂地实例介绍如何整合Struts,Spring,Hibernate,网上现有的例子虽然也能达到目的,但功能都比较单一,复杂的例子时会有...
一步步教你搭建SSH(Struts+Hibernate+Spring)项目