文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>ssh配置

ssh配置

时间:2010-06-17  来源:mozhx

ssh配置--使用AOP配置事务管理   在spring2.0里创建的applicationContext-common.xml文件里,头部的aop与tx代码是没有的,需要手工添加上去,可以在下载的spring源码包里的示例文件中copy过来。 spring2.0里还有一个bug就是使用spring的dataSource时需要加上两个文件:commons-pool.jar和commons-dbcp.jar applicationContext-common.xml   <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
 
 <bean id="dataSource"
   class="org.apache.commons.dbcp.BasicDataSource">
   <property name="driverClassName"
    value="com.mysql.jdbc.Driver">
   </property>
   <property name="url"
    value="jdbc:mysql://localhost:3306/newspaper">
   </property>
   <property name="username" value="root"></property>
   <property name="password" value="a12345"></property>
  </bean>

  <bean id="sessionFactory"
   class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="dataSource">
    <ref bean="dataSource" />
   </property>
   <property name="configLocation">
    <value>classpath:hibernate.cfg.xml</value>
   </property>
   <property name="hibernateProperties">
    <props>
     <prop key="hibernate.dialect">
      org.hibernate.dialect.MySQLDialect
     </prop>
 <prop key="hibernate.show_sql">true</prop>

    </props>
   </property>
  </bean>
  <!-- 配置事务管理器 -->
  <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
   <property name="sessionFactory">
    <ref local="sessionFactory"/>
   </property>
  </bean>
<!-- 配置事务特性 --> 
  <tx:advice id="txAdvice" transaction-manager="transactionManager" >
   <tx:attributes>
    <!-- 鍦ㄥ紑鍙戠殑鏃跺€欏彲浠ヨ繖鏍峰畾涔夛紝浣嗛儴缃茬殑鏃跺€欎竴瀹氳?璇︾粏瀹氫箟 -->
    <tx:method name="*" propagation="REQUIRED"/>
   <!-- 
    <tx:method name="add*" propagation="REQUIRED"/>
    <tx:method name="del*" propagation="REQUIRED"/>
    <tx:method name="update*" propagation="REQUIRED"/>
    <tx:method name="*" read-only="true"/>
   -->
   </tx:attributes>
  </tx:advice>
  
  <!-- 配置哪些类的方法进行事务管理 -->
  <aop:config>
   <aop:pointcut id="allManagerMethod" expression="execution(* com.bjsxt.oa.manager.*.*(..))"/>
   <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
  </aop:config>

</beans>
    web.xml配置   <!-- spring配置 -->
  <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>
 
  <!-- Spring character encoding filter -->
 
  <filter>
    <filter-name>Spring character encoding filter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
     <param-name>encoding</param-name>
     <param-value>GBK</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>Spring character encoding filter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
 <!--配置OpenSessionInViewFilter-->
 <filter>
  <filter-name>open session in view</filter-name>
  <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>open session in view</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>   
    struts-config.xml配置   <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
  <data-sources />
  <form-beans>
    <form-bean name="studentForm" type="com.student.web.struts.form.StudentForm" />
     <form-bean name="loginForm" type="com.student.web.struts.form.LoginForm" />
     <form-bean name="userForm" type="com.student.web.struts.form.UserForm"></form-bean>
  </form-beans>
 
  <global-exceptions>
   <!----> <exception
    key="errors.detail"
    type="java.lang.Exception"
    path="/common/exception.jsp"
    handler="com.student.web.struts.action.SystemExceptionHandler"
    scope="request"
    ></exception>
  </global-exceptions>
 
  <global-forwards>
    <forward name="pub_del_succes" path="/common/pub_del_succes.jsp" />
     <forward name="pub_update_succes" path="/common/pub_update_succes.jsp" />
  <forward name="pub_add_succes" path="/common/pub_add_succes.jsp" />
  </global-forwards>
 
  <action-mappings>
      <action
      attribute="loginForm"
      input="/login.jsp"
      name="loginForm"
      parameter="command"
      path="/login"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy" >
    <forward name="back_index" path="/index.jsp"></forward>
  </action>
   
    <action path="/baseAction" type="com.student.web.struts.action.BaseAction" />
  </action-mappings>
 
   <message-resources parameter="com.student.web.struts.MessageResources" />
</struts-config>
 
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载