<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 狂淘 閱讀(531) 評論(0)  編輯  收藏 所屬分類: struts2.0 spring hiberate
    主站蜘蛛池模板: 色猫咪免费人成网站在线观看| 永久免费观看黄网站| 久久精品免费观看国产| 亚洲熟妇av一区二区三区漫画| 一级做a爰片久久毛片免费陪| 亚洲精品无码久久毛片| 日日躁狠狠躁狠狠爱免费视频 | 三年片在线观看免费| 亚洲色欲色欱wwW在线| 无码人妻一区二区三区免费| 亚洲中文字幕无码爆乳app| 热久久精品免费视频| 国产亚洲精品美女久久久久久下载| 99久久免费看国产精品| 在线电影你懂的亚洲| 中文字幕在线免费看线人| 国产亚洲美女精品久久久2020| 亚洲无码一区二区三区| 国产精品四虎在线观看免费| 羞羞漫画页面免费入口欢迎你| 免费H网站在线观看的| 亚洲卡一卡2卡三卡4卡无卡三 | 国产精品亚洲专区一区| 亚洲免费日韩无码系列| 久久这里只精品热免费99| 亚洲国产精品成人精品小说| a在线免费观看视频| 亚洲美女视频免费| 在线永久免费观看黄网站| 在线免费视频你懂的| 免费成人黄色大片| 婷婷亚洲综合一区二区| 亚洲午夜福利717| 无码人妻精品中文字幕免费东京热| 亚洲精品天堂无码中文字幕| 亚洲成a人无码av波多野按摩| 337p日本欧洲亚洲大胆人人| 亚洲日韩欧洲无码av夜夜摸| 99久久这里只精品国产免费| 毛片基地看看成人免费| youjizz亚洲|