日期:2014-05-17  浏览次数:20787 次

ssh集成
1.在Struts2中添加的内容
<constant name="struts.objectFactory" value="spring"/>
<constant name="struts.i18n.encoding" value="GBK"></constant>


2.在web.xml中添加
<context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
  <listener-class>
    org.springframework.web.context.ContextLoaderListener
 </listener-class>
</listener>


struts省事了:

  <package name="default" namespace="/" extends="struts-default">
     <action name="" class="">
        <result name=""></result>
     </action>
  </package>

---这个是人品好的applicationContext.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:jasws="http://cxf.apache.org/jaxws" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
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">

----全都有了
<!-- 实现基于Hibernate的事物管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 通知 测试的是save开始的方法,其他的同理-->
<tx:advice id="smAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- 对biz或者实现方法进行管理 -->
<aop:config>
<aop:pointcut expression="execution(* dao.*.*(..))" id="smMethod" />
<aop:advisor pointcut-ref="smMethod" advice-ref="smAdvice" />
</aop:config>


----反向生成hibernate对应的表:
<property name="hbm2ddl.auto">create</property>
---反向生成从applicationContext.xml中的写法
<prop key="hibernate.hbm2ddl.auto">create</prop>


shushang1109@qq.com

------解决方案--------------------
您是在分享~~感谢分享!
------解决方案---------------