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

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

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

    狂淘

    www.kuangtao.net

       :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      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環(huán)境變量
    build.xml



    <?xml version="1.0" encoding="GBK"?>
    <project name="OA【01】系統(tǒng)構建腳本" 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
    主站蜘蛛池模板: 亚洲国产精品免费观看| 亚洲日本在线播放| 亚洲精品黄色视频在线观看免费资源 | 国产午夜影视大全免费观看 | 亚洲日韩国产二区无码| 国产无限免费观看黄网站| 亚洲国产精品碰碰| 一区二区三区在线免费 | 中文字幕无线码免费人妻| 50岁老女人的毛片免费观看| 国产综合亚洲专区在线| 中国亚洲呦女专区| 日韩高清免费观看| 看一级毛片免费观看视频| 亚洲精品视频久久久| 亚洲视频无码高清在线| 成年人网站在线免费观看| 亚洲看片无码在线视频| 国产免费爽爽视频免费可以看| 久久精品国产亚洲AV麻豆网站| 一级特黄色毛片免费看| 成年女人毛片免费视频| 精品国产日韩亚洲一区91| 亚洲第一区精品日韩在线播放| 亚洲中文久久精品无码1| 最近2019中文免费字幕| 深夜a级毛片免费无码| 亚洲精品V欧洲精品V日韩精品 | 99re8这里有精品热视频免费| 日韩免费观看视频| 51午夜精品免费视频| 亚洲成A人片77777国产| 国产色无码精品视频免费| 亚洲第一二三四区| 久久久久国色av免费看| 成人亚洲国产va天堂| 曰曰鲁夜夜免费播放视频| 精品国产日韩亚洲一区在线| 亚洲AV永久无码区成人网站| 成人影片麻豆国产影片免费观看| 亚洲码一区二区三区|