SSH三大框架整合集成.doc
上传人:sy****28 上传时间:2024-09-15 格式:DOC 页数:6 大小:248KB 金币:16 举报 版权申诉
预览加载中,请您耐心等待几秒...

SSH三大框架整合集成.doc

SSH三大框架整合集成.doc

预览

在线预览结束,喜欢就下载吧,查找使用更方便

16 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

首先是各个框架自己搭建按顺序先hibernate后spring最后添加struts2Spring与hibernate整合时,用到了spring框架下的HibernateDaoSupportimportorg.springframework.orm.hibernate3.support.HibernateDaoSupport这个类包含属性importorg.hibernate.SessionFactory;而这个属性sessionFactory又依赖配置文件hibernate.cfg.xml所以在spring的配置文件applicationContext.xml文件中配置以下内容,在文档页面上copy改sessionfactory原页面上的内容经过简化的sessionfactory第二种方法transaction事务的切入和声明,必须有事务不然无法对数据库同步,简单是事务配置是在hibernate.cfg.xml中添加自动提交属性,如下<propertyname="connection.autocommit">true</property>实际应用时在applicationContext.xml中配置事务并声明为切面继续整合struts2除了基本的jar包外,还需要一个struts-2.1.6\lib文件下的struts2-spring-plugin-2.1.6.jar改包然后是web.xml中的配置<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><context-param><param-name>contextConfigLocation</param-name><param-value>classpath*:applicationContext.xml</param-value></context-param><filter><filter-name>openSessionInviwe</filter-name><filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class></filter><filter-mapping><filter-name>openSessionInviwe</filter-name><url-pattern>/*</url-pattern></filter-mapping><filter><filter-name>characterEncoding</filter-name><filter-class>com.pb.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param>属性名encoding去引用的类里面查找</filter><filter-mapping><filter-name>characterEncoding</filter-name><url-pattern>/*</url-pattern></filter-mapping>