<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 22, comments - 32, trackbacks - 0, articles - 73
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理
    這里為什么使用struts2.0.14這個版本呢??請看官網的文章如下:

    24 November 2008 - Struts 2.0.14 General Availability Release

    The latest release of Struts 2 is Struts 2.0.14, which was promoted to "General Availability" on 24 November 2008.

    For changes included in Struts 2.0.14, see the release notes. Struts 2.0.14 is a bugfix release for version 2.0.12, which provided important security fixes. Struts 2.0.14 addresses two major bugs introduced with these security fixes, keeping the FilterDispatcher from serving built in static resources, and keeping conversion error messages from being displayed. All developers are strongly encouraged to update existing Struts 2 applications to Struts 2.0.14.

    如果你的英語不差的話,自己去看下吧.這段英語的大概意思是,Struts 2.0.14修正了Struts 2.0.12 的兩個主要的bug ;并且建議開發者更新到Struts 2.0.14
    這個版本.Struts 2.0.14 General Availability Release 這是個通用的開發版本.
    其實我在整合這個S2SH時,struts2 的最新版本是struts2.1.16 這個也是穩家版本,不過最新的版本網上資料很少.所以...........! 如果自己學的話可以選擇這個兩個版本.
    下邊是整合的全過程:
    主要是jar包的引入,我個人比較不喜歡用IDE 工具自動引入jar包,所以下邊是自己用的jar的引入,這樣可以省去相關jar 的沖突;

    1:首先struts2.0.14所需要的jar包如下:
    commons-logging-1.0.4  ;
    freemarker-2.3.8
     ognl-2.6.11
    struts2-core-2.0.14
    xwork-2.0.7
    struts2-spring-plugin-2.0.14  這是整合spring 必需的jar 包,從它的名字就可以看出來了!   

    2:hiberante3.2 jar 包如下 這是我的工程必需的,如果你的工程要用到其它的jar包可以去看一看hibernate 的必讀文件那里有很詳細的解釋;
                這個是做一般的工程,引入最少的jar 了,一般的項目都可以了!

    antlr-2.7.6         cglib-2.1.3     commons-collections-2.1.1    commons-logging-1.0.4      dom4j-1.6.1  
    ehcache-1.2.3    hibernate3     jaas        jaxen-1.1-beta-7     jdbc2_0-stdext     jta    log4j-1.2.11  
    xml-apis             asm             asm-attrs 

    如果你自己不做整合的,就是單獨做hibernate 學習,本人建議你把所有jar 都導入項目的lib目錄下!這里不在做任何解釋了!

    3:  spring 2.5.6  相關的jar 也是做項目最少引入的jar包了,如果自己還需要特定的自己去引入;

        aspectjrt    aspectjweaver   ( 這兩個是AOP 相關的jar包,因為spring  2.5的AOP實現,沒有自己去做,也用到了第三方組件,分開了,這好像和2.0版本有出入!有關細節,請自己去查閱相關文檔)
        spring

    好的,這三個框架所有jar 包,都介紹完了,(不要奇怪我的所有jar 包沒有后綴名,是我自己給隱藏了)

    好的進入主題了(順序最好 hibernate --->spring---->struts)

    1:把相關的hibernate  jar 包導入項目lib 目錄下!
    2: 把spring  相關jar   包導入項目lib 目錄下!
    3: 把struts2相關jar   包導入項目lib 目錄下!

    三者整合:
    web.xml文件如下里邊都有解釋自己看吧:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

     <!-- 配置spring監聽器和上下文變量 -->
     <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>
     <!-- spring end -->

    <!-- 配置字符過濾器-->
     <filter>
      <filter-name>encodingFilter</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>encodingFilter</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>

     <!--讓spring來過濾管理Hiberante中的session-->
     <filter>
      <filter-name>lazyLoadingFilter</filter-name>
      <filter-class>
       org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
      </filter-class>
     </filter>

     <!-- spring end -->

     <!-- 增加struts2所需要的過濾器,以便在服務器啟動時,攔截URL請求 -->
     <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
       org.apache.struts2.dispatcher.FilterDispatcher
      </filter-class>
     </filter>

     <filter-mapping>
      <filter-name>lazyLoadingFilter</filter-name>
      <url-pattern>*.action</url-pattern>
     </filter-mapping>


     <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>
      </web-app>


    applicationContext-common.xml 文件:其中我使用了,DBCP數據庫連接波,如果你自己想用,
                               還的去下載相關的jar 包( commons-dbcp-1.2.2   commons-pool-1.3)記著引入哦!

    我下邊注釋掉的就是沒有用數據庫連接池的,也就是不把src目錄下的hibernate.cfg.xml刪除.上邊用到的數據庫連接池的,就不用這個文件了,直接都用spring來管理啦!!!!

    <?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">
     <!-- 用DBCP數據庫連接波來配置hibernate數據庫連接 -->
     
      <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/oa"></property>
      <property name="username" value="root"></property>
      <property name="password" value="root"></property>
      </bean>
     
     <!-- 配置sessionFactory -->
      
      <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="dataSource">
      <ref bean="dataSource" />
      </property>
      <property name="hibernateProperties">
      <props>
      <prop key="hibernate.dialect">
      org.hibernate.dialect.MySQLDialect
      </prop>
      <prop key="hibernate.show_sql">true</prop>
      <prop key="format_sql">true</prop>
      <prop key="hibernate.hbm2ddl.auto">update</prop>
      </props>
      </property>
      <property name="mappingResources">
      <list>
      <value>com/oa/model/Person.hbm.xml</value>
      <value>com/oa/model/Organization.hbm.xml</value>
      </list>
      </property>
      </bean>
      
    <!-- 讓spring管理sessionFactory的加一種方法 ,就是不刪除hibernate.cfg.xml文件;
     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="configLocation">
       <value>classpath:hibernate.cfg.xml</value>
      </property>
     </bean>
    --> 
      
     <!-- 配置hibernate事物讓spring來管理 -->
     <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="delete*" 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.oa.manager.*.*(..))" />
      <aop:advisor pointcut-ref="allManagerMethod"
       advice-ref="txAdvice" />
     </aop:config>
    </beans>

    對了還需要注意的一個地方就是如果用了,我這種數據庫連接池技術,得把你的數據庫驅動類,復制tomcat lib 目錄下.不然會報錯的!

    好了三個東西整合好,我也是費了九牛二虎之力才整合成功的.
    如果有什么問題發我的郵箱一起交流:zzzlyr@163.com




    評論

    # re: struts2.0.14+hibernate3.2+spring2.5.6+tomcat6.0+mysql5.0整合全過程  回復  更多評論   

    2009-08-16 08:47 by Down_light_Spotlight
    有沒有配圖 這個東西看得比較辛苦

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲人成网站看在线播放| 亚洲va久久久噜噜噜久久狠狠| 2019亚洲午夜无码天堂| 84pao强力永久免费高清| 亚洲图片在线观看| 啦啦啦完整版免费视频在线观看 | 四虎成人精品一区二区免费网站| 色婷五月综激情亚洲综合| 无限动漫网在线观看免费| 亚洲熟妇自偷自拍另欧美| 性做久久久久免费观看| 思思久久99热免费精品6| 国产亚洲精品拍拍拍拍拍| 国内精品免费久久影院| 亚洲高清无在码在线无弹窗 | 亚洲免费一区二区| 国产亚洲一区二区三区在线不卡 | 日本黄网站动漫视频免费| 亚洲天堂电影在线观看| 四虎成人免费影院网址| 无码日韩人妻AV一区免费l| 久久亚洲国产成人影院网站| 99视频免费观看| 亚洲 欧洲 视频 伦小说| 国产男女猛烈无遮挡免费视频| 国产免费人成视频在线播放播 | 日本免费网站观看| 一级特黄aaa大片免费看| 无码久久精品国产亚洲Av影片| 人与禽交免费网站视频| 免费精品视频在线| 久久久亚洲欧洲日产国码aⅴ| 毛片免费观看视频| 久久精品成人免费国产片小草 | 亚洲最大在线观看| 日本免费人成黄页在线观看视频 | 在线视频观看免费视频18| 思思久久99热免费精品6| 亚洲国产成人精品电影| 亚洲AV无码乱码在线观看| 精品熟女少妇a∨免费久久|