SSH集成的一个样例,放到这里方便自己以后使用。其实就是一些配置,也没什么先后顺序。
web.xml增加
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
修改Struts-config.xml中action的type属性为org.springframework.web.struts.DelegatingActionProxy
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans >
<form-bean name="userForm" type="cn.ineeke.ssh.web.form.UserForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="userForm"
input="/index.jsp"
name="userForm"
parameter="action"
path="/user"
scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="userlist" path="/list.jsp"/>
<forward name="toUpdate" path="/user_info.jsp"/>
</action>
</action-mappings>
<message-resources parameter="cn.ineeke.ssh.web.ApplicationResources" />
</struts-config>
对action进行注入,name属性必须与上面配置信息中action的path一致,class属性值为具体的action类。
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean name="/user" class="cn.ineeke.ssh.web.action.UserAction">
<property name="userBiz" ref="userBiz"/>
</bean>
</beans>
hibernate.cfg.xml的配置
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.username">root</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/ssh
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="myeclipse.connection.profile">mysql</property>
<property name="connection.password">www.ineeke.com</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="show_sql">true</property>
<mapping resource="cn/ineeke/ssh/entity/TUser.hbm.xml" />
</session-factory>
</hibernate-configuration>
配置AOP
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<!-- 配置sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 配置事务的传播性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 配置哪些类及其哪些方法参与该事务 -->
<aop:config>
<aop:pointcut id="allMethod" expression="execution(* cn.ineeke.ssh.biz.impl.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allMethod"/>
</aop:config>
</beans>
分享到:
相关推荐
SSH集成 Struts+spring+hibernate集成SSH集成 Struts+spring+hibernate集成
struts+spring+hibernate集成说明,英文的,可以练练英文,又可以看看技术,很不错滴。
Struts2.3.28+spring4.1.6+hibernate4.3.8整合总结(注解),测试环境使用myeclipse2014,jdk1.6
SSH是 struts+spring+hibernate的一个集成框架,是目前比较流行的一种Web应用程序开源框架 现在的结构是,Struts负责显示层,Hibernate负责持久层,Spring负责中间的业务层,另外,由于Spring使用的依赖注射以及AOP...
Struts+Spring+Hibernate+WebService集成架构
struts1+spring2.5+hibernate3.0,ssh集成的一个例子 数据库是mysql的,包里带文件用的时候导入到数据库就好了。 有什么不明白的地方留言给我
Struts2+Spring+Hibernate集成开发环境的配置小例子。
SSH整合开发完整例子(Struts+spring+hibernate完整开发). 以及包含完整的项目说明文档.
Struts 2+Spring 3+Hibernate框架技术精讲与整合案例2Struts 2+Spring 3+Hibernate框架技术精讲与整合案例2Struts 2+Spring 3+Hibernate框架技术精讲与整合案例2Struts 2+Spring 3+Hibernate框架技术精讲与整合案例2
包含struts1+spring+hibernate集成jar包,不用再去一个一个收集下载啦~
本人自己动手集成的struts+spring+hibernate 网站后台管理系统,希望对刚学习struts的朋友带来一定的帮助,这是我上传此文件的最大愿望,里面有三个框架所需要的jar包和所有的配置文件,只要下载即可运行,不需要...
JavaEE多层架构Struts2+Spring3+Hibernate3+Ajax的整合JavaEE多层架构Struts2+Spring3+Hibernate3+Ajax的整合JavaEE多层架构Struts2+Spring3+Hibernate3+Ajax的整合
在此贴出来与大家共享,绝对真实,提供数据库,需求文档,源代码,只要部署着Myclipse上,配置好数据库直接可以运行。如不清楚,我里面有说明文档。
一个简单的Struts+Spring+Hibernate的登录模块的代码,含数据库代码和部分简单说明(适合刚接触Struts+Spring+Hibernate框架的开发者); 本例采用myEclipse6.0.1和tomcat6开发,可直接导入myeclipse工程运行...
struts+spring+hibernate框架集成
struts1+spring+hibernate+ibatis集成
2.Action里通过struts2-spring-plugin.jar插件自动根据名字注入。 3.Ajax无刷新异步调用Struts2,返回Json数据,以用户注册为例。 4.在服务端分页查询功能,优点:实时性:跳页才查询。数据量小:只加载当前页的记录...
Struts+Spring+Hibernate(ssh)集成(实现增删改查) shop.sql是数据库文件
Struts+Spring+Hibernate+WebService集成架构.doc