<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
    主站蜘蛛池模板: 四虎影院永久免费观看| 日韩亚洲国产高清免费视频| 四虎永久免费地址在线观看| 国产亚洲中文日本不卡二区| 亚洲第一网站免费视频| 亚洲精品视频久久| 成年人网站免费视频| 亚洲国产午夜电影在线入口| 99热在线精品免费全部my| 亚洲av成人综合网| 免费无码黄十八禁网站在线观看 | 青青草免费在线视频| 亚洲а∨天堂久久精品9966| 影音先锋在线免费观看| 亚洲另类无码专区丝袜| 国产jizzjizz视频全部免费| 一道本不卡免费视频| 亚洲午夜国产精品无码| 无码午夜成人1000部免费视频| 久久精品国产亚洲AV高清热 | 中文字幕中韩乱码亚洲大片| 成人网站免费大全日韩国产 | 国产AV无码专区亚洲A∨毛片| 亚洲视频在线观看免费| 亚洲电影在线免费观看| 国产成人免费a在线视频app| j8又粗又长又硬又爽免费视频| 亚洲av伊人久久综合密臀性色 | 2021国内精品久久久久精免费| 一区二区亚洲精品精华液| xvideos亚洲永久网址| 巨胸喷奶水视频www免费视频| 亚洲影院在线观看| 在线精品免费视频| 二个人看的www免费视频| 亚洲三级在线视频| 亚洲午夜福利精品久久| 4455永久在线观免费看| 国产成人亚洲午夜电影| 亚洲黄色一级毛片| 免费在线观看黄网站|