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

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

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

    狂淘

    www.kuangtao.net

       :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      6 隨筆 :: 185 文章 :: 68 評論 :: 0 Trackbacks
    13:18:45
    1.web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns=http://java.sun.com/xml/ns/j2ee                          
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
     
     <!-- struts2 spring 整合 -->
     <listener>
      <listener-class>
       org.springframework.web.context.ContextLoaderListener
      </listener-class>
     </listener>
     <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
       /WEB-INF/classes/applicationContext-*.xml,classpath*:applicationContext-*.xml
      </param-value>
     </context-param>

     <!--  <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
      /WEB-INF/classes/applicationContext.xml
      </param-value>
      </context-param>-->
      
      <!-- 自動關閉Hibernatesession -->
     <filter>
      <filter-name>hibernateFilter</filter-name>
      <filter-class>
       org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
      </filter-class>
     </filter>
     <filter-mapping>
      <filter-name>hibernateFilter</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>
    <!-- 亂碼 -->
     <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>

     <!-- struts2.0配置 -->
     <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
       org.apache.struts2.dispatcher.FilterDispatcher
      </filter-class>
     </filter>
     <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>

     

     <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
     </welcome-file-list>
    </web-app>
    2.  struts2-spring-plugin-2.0.14.jar
    3.applicationContext-actions.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.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    <bean id="loginManger" class="com.xushi.Manager.Impl.LoginSericeImpl"/>
    <bean id="login" class="com.xushi.action.LoginAction">
     <property name="loginManger" ref="loginManger"></property>
    </bean>
    </beans>
    4.applicationContext-beans.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.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    </beans>

    5.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.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <!-- 配置sessionFactory -->
     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
      <property name="configLocation">
       <value>classpath:hibernate.cfg.xml</value>
      </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="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.xushi.manager.*.*(..))"/>
         <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
        </aop:config>         
    </beans>

    6記住配置ant環境變量
    build.xml



    <?xml version="1.0" encoding="GBK"?>
    <project name="OA【01】系統構建腳本" default="生成Hibernate配置文件" basedir=".">

        <property name="src.dir" value="${basedir}/src"/>
     <property name="xdoclet.home" value="D:/xdoclet-plugins-dist-1.0.4"/>

        <!-- Build classpath -->
        <path id="xdoclet.task.classpath">
           <fileset dir="${xdoclet.home}/lib">
              <include name="**/*.jar"/>
           </fileset>
          <!--   <fileset dir="${xdoclet.home}/plugins">
              <include name="**/*.jar"/>
           </fileset>-->
        </path>
     <taskdef 
      name="xdoclet"
      classname="org.xdoclet.ant.XDocletTask"
      classpathref="xdoclet.task.classpath"
     />
     
     <target name="生成Hibernate配置文件">
      <xdoclet>
       <fileset dir="${src.dir}/com/xushi/model">
        <include name="**/*.java"/>
       </fileset>   
       <component
        classname="org.xdoclet.plugin.hibernate.HibernateConfigPlugin"
        destdir="${src.dir}"
        version="3.0"
        hbm2ddlauto="update"
        jdbcurl="jdbc:mysql://localhost/oa"
        jdbcdriver="com.mysql.jdbc.Driver"
        jdbcusername="root"
        jdbcpassword="wzy"
        dialect="org.hibernate.dialect.MySQLDialect"
        showsql="true"
       />
      </xdoclet>
     </target>
     <target name="生成hibernate映射文件">
      <xdoclet>
       <fileset dir="${src.dir}/com/xushi/model">
        <include name="**/*.java"/>
       </fileset>
       <component
        classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin"
        version="3.0"
        destdir="${src.dir}"
       />
      </xdoclet>
     </target>
    </project>


     7.Orgnization.java

    package com.xushi.model;

    import java.util.Set;

    /**
     *
     * @author Administrator
     * @hibernate.class table="T_Orgnization"
     *
     */
    public class Orgnization {
     
     /**
      * @hibernate.id
      *   generator-class="native"
      */
     private int id;

     /**
      * @hibernate.property
      */
     private String name;
     
     /**
      * @hibernate.property
      */
     private String sn;
     
     /**
      * @hibernate.property
      */
     private String description;
     
     /**
      * @hibernate.many-to-one
      *   column="pid"
      */
     private Orgnization parent;
     
     /**
      * @hibernate.set inverse="true" lazy="extra"
      * @hibernate.key column="pid"
      * @hibernate.one-to-many class="com.xushi.model.Orgnization"
      */
     private Set children;
     
     
     public Set getChildren() {
      return children;
     }
     public void setChildren(Set children) {
      this.children = children;
     }
     public String getDescription() {
      return description;
     }
     public void setDescription(String description) {
      this.description = description;
     }
     public int getId() {
      return id;
     }
     public void setId(int id) {
      this.id = id;
     }
     public String getName() {
      return name;
     }
     public void setName(String name) {
      this.name = name;
     }
     public Orgnization getParent() {
      return parent;
     }
     public void setParent(Orgnization parent) {
      this.parent = parent;
     }
     public String getSn() {
      return sn;
     }
     public void setSn(String sn) {
      this.sn = sn;
     }
    }
    8.Person.java

    package com.xushi.model;

    /**
     *
     * @author Administrator
     * @hibernate.class table="T_Person"
     */
    public class Person {
     
     /**
      * @hibernate.id
      *   generator-class="native"
      */
     private int id;
     
     /**
      * @hibernate.property
      */
     private String name;
     
     /**
      * @hibernate.property
      */
     private String sex;
     
     /**
      * @hibernate.property
      */
     private String address;
     
     /**
      * @hibernate.property
      */
     private String duty;
     
     /**
      * @hibernate.property
      */
     private String phone;
     
     /**
      * @hibernate.property
      */
     private String description;
     
     /**
      * @hibernate.many-to-one
      */
     private Orgnization org;
     
     public String getAddress() {
      return address;
     }
     public void setAddress(String address) {
      this.address = address;
     }
     public String getDescription() {
      return description;
     }
     public void setDescription(String description) {
      this.description = description;
     }
     public String getDuty() {
      return duty;
     }
     public void setDuty(String duty) {
      this.duty = duty;
     }
     public int getId() {
      return id;
     }
     public void setId(int id) {
      this.id = id;
     }
     public String getName() {
      return name;
     }
     public void setName(String name) {
      this.name = name;
     }
     public String getPhone() {
      return phone;
     }
     public void setPhone(String phone) {
      this.phone = phone;
     }
     public String getSex() {
      return sex;
     }
     public void setSex(String sex) {
      this.sex = sex;
     }
     public Orgnization getOrg() {
      return org;
     }
     public void setOrg(Orgnization org) {
      this.org = org;
     }
    }

    posted on 2009-10-24 13:19 狂淘 閱讀(541) 評論(0)  編輯  收藏 所屬分類: struts2.0 spring hiberate
    主站蜘蛛池模板: 精品一卡2卡三卡4卡免费视频| 特级无码毛片免费视频尤物| 精品国产亚洲一区二区在线观看| 黑人大战亚洲人精品一区| 成全视频高清免费观看电视剧| 久久亚洲私人国产精品| 免费无码又爽又刺激高潮| 亚洲码在线中文在线观看| 国产一区二区三区免费观看在线| 91天堂素人精品系列全集亚洲| 在线免费观看一区二区三区| 99视频免费在线观看| 久久精品亚洲乱码伦伦中文| 18禁美女黄网站色大片免费观看| 亚洲电影一区二区| 精品久久免费视频| 久久久免费精品re6| 国产精品亚洲综合一区在线观看 | 日韩少妇内射免费播放| 欧洲精品免费一区二区三区| 香蕉免费一级视频在线观看| 亚洲熟妇AV一区二区三区浪潮| 在线a亚洲v天堂网2019无码| 全免费一级毛片在线播放| 免费国产在线视频| g0g0人体全免费高清大胆视频| 在线亚洲午夜片AV大片| 亚洲va中文字幕无码久久| 国产免费观看黄AV片 | 91在线视频免费91| 亚洲人成电影网站| 亚洲s色大片在线观看| 亚洲国产精品综合久久一线| ssswww日本免费网站片| 亚洲avav天堂av在线网爱情| 国产成人aaa在线视频免费观看| h视频在线观看免费| 亚洲av无码av在线播放| 亚洲人成在线播放网站| 99精品视频在线免费观看| 精品国产福利尤物免费|