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

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

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

    jinfeng_wang

    G-G-S,D-D-U!

    BlogJava 首頁(yè) 新隨筆 聯(lián)系 聚合 管理
      400 Posts :: 0 Stories :: 296 Comments :: 0 Trackbacks
    http://www.logemann.org/day/archives/000148.html


    For all those out there using Spring together with Struts, i created a small howTo regarding automatic generation of relevant files, especially the boring action-servlet-xml file which must be in synch with your struts-config.xml, at least for all Struts actions which should be injected by Spring.

    Lets start with the Action class:

    /**
    * Action to delete a Client
    * Date: 09.02.2005
    * Time: 15:29:15
    *
    * @author Logemann - Logentis e.K. (ml@logentis.de)
    * @version $Id$
    * @struts.action path="clientDelete" validate="false"
    * type="org.springframework.web.struts.DelegatingActionProxy"
    * name="emptyform"
    * @struts.action-forward name="back"
    * path="/clientManager.html" redirect="true"
    * @spring.bean name="clientDelete"
    */
    public class ClientDeleteAction extends Action {

    ClientManager clientManagerService;



    /**

    * Spring injection

    *

    * @param clientManagerService clientManagerService

    * @spring.property ref="clientManagerService"

    */

    public void setClientManagerService(ClientManager clientManagerService) {

    this.clientManagerService = clientManagerService;

    }

    [..]


    With this tags, the ant build target outlined below will create a struts-config.xml and the necessary action-servlet.xml needed by Spring. Lets see how the target looks:

    <path id="classpath">

    <fileset dir="c:/xdoclet-1.2.2" includes="*.jar"/>
    <fileset dir="c:/j2sdkee1.3.1/lib" includes="*.jar"/>
    <fileset dir="c:/struts/lib" includes="struts.jar"/>
    </path>

    <taskdef name="springdoclet"
    classname="xdoclet.modules.spring.SpringDocletTask"
    classpathref="classpath"/>

    <taskdef name="webdoclet"
    classname="xdoclet.modules.web.WebDocletTask"
    classpathref="classpath"/>

    <target name="myTest">
    <webdoclet destDir="c:\" force="true" verbose="true">
    <fileset dir="${src.dir}">
    <include name="**/*Form.java" />
    <include name="**/*Action.java" />
    <include name="**/*Servlet.java" />
    </fileset>
    <strutsconfigxml version="1.1" validateXml="true"/>
    </webdoclet>

    <springdoclet destDir="c:\" verbose="true">
    <fileset dir="${src.dir}">
    <include name="**/*Action.java" />
    </fileset>
    <springxml destinationFile="action-servlet.xml"/>
    </springdoclet>
    </target>

    Be sure to modify the classpath definition and the destDir values of springdoclet and webdoclet to suit your needs. Right now the Spring task only searches for Actions in order to create action-servlet.xml, if you also want to create your normal service beans like ClientManagerService, you should create another springdoclet task and output things to applicationContext.xml if you like.

    But this is mostly users choice, as you know, Spring supports from one to many bean definition files and its up to you how you want to have your spring xml world.

    This will be created when you run the mentioned target:

    (action-servlet.xml)


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC
    "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans
    default-autowire="no"
    default-lazy-init="false"
    default-dependency-check="none"
    >

    <bean
    name="clientDelete"
    class="de.logentis.versysng.action.clientmanager.ClientDeleteAction"
    >

    <property name="clientManagerService">

    <ref bean="clientManagerService"/>
    </property>

    </bean>

    <!--
    To include additional bean definitions for Spring in the generated
    application context file, add a file to your XDoclet merge directory
    called spring-beans.xml that contains the <bean></bean> markup.
    -->
    </beans>


    (struts-config.xml)


    <?xml version="1.0" encoding="UTF-8" ?>

    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

    <struts-config>

    <!-- ========== Data Sources Definitions =================================== -->
    <!--
    Define your Struts data sources in a file called struts-data-sources.xml and place
    it in your merge directory.
    -->

    <!-- ========== Form Bean Definitions =================================== -->
    <form-beans>

    <!--
    If you have non XDoclet forms, define them in a file called struts-forms.xml and
    place it in your merge directory.
    -->
    </form-beans>

    <!-- ========== Global Exceptions Definitions =================================== -->
    <!--
    Define your exceptions in a file called global-exceptions.xml and place
    it in your merge directory.
    -->

    <!-- ========== Global Forward Definitions =================================== -->
    <!--
    Define your forwards in a file called global-forwards.xml and place
    it in your merge directory.
    -->

    <!-- ========== Action Mapping Definitions =================================== -->
    <action-mappings>
    <action
    path="clientDelete"
    type="org.springframework.web.struts.DelegatingActionProxy"
    name="emptyform"
    scope="request"
    unknown="false"
    validate="false"
    >
    <forward
    name="back"
    path="/clientManager.html"
    redirect="true"
    />
    </action>

    <!-- If you have non XDoclet actions, define them in a file called struts-actions.xml and place it in your merge directory. -->
    </action-mappings>

    <!-- Define your Struts controller in a file called struts-controller.xml and place it in your merge directory. -->

    <!-- Define your Struts message-resources in a file called struts-message-resources.xml and place it in your merge directory. -->

    <!-- Define your Struts plugins in a file called struts-plugins.xml and place it in your merge directory. -->

    </struts-config>

    posted on 2008-03-20 09:42 jinfeng_wang 閱讀(891) 評(píng)論(1)  編輯  收藏 所屬分類: springantjavastructs

    評(píng)論

    # re: XDoclet Spring+Struts HowTo zz 2009-07-19 18:56 ddsfsdf@sfsdf.de
    Please remove this blog post or edit it in a way that my email adress is no longer in there!

    Thanks.  回復(fù)  更多評(píng)論
      

    主站蜘蛛池模板: 亚洲欧洲校园自拍都市| 四虎永久免费网站免费观看| 日本一区午夜艳熟免费| 91成人免费福利网站在线| 美丽的姑娘免费观看在线播放| 最新欧洲大片免费在线| 免费午夜爽爽爽WWW视频十八禁 | 亚洲AV无码成H人在线观看| 亚洲视频在线精品| 亚洲成av人片在线看片| 国产又黄又爽又猛免费app| 国产亚洲精品影视在线产品| 亚洲国产精品午夜电影 | 国产美女无遮挡免费视频 | 久久久久亚洲av成人无码电影| 欧亚一级毛片免费看| 免费一区二区三区| 免费看美女让人桶尿口| 亚洲AV日韩AV高潮无码专区| 亚洲日本中文字幕天天更新| 免费人成黄页在线观看日本| 久久久久久久亚洲Av无码| 久青草国产免费观看| 毛片免费观看的视频| 亚洲av中文无码乱人伦在线播放 | 亚洲精品和日本精品| 亚洲综合中文字幕无线码| 中文字字幕在线高清免费电影| 暖暖免费高清日本一区二区三区| 亚洲人成亚洲精品| 青青操免费在线视频| 久久久久亚洲av无码专区喷水| 拨牐拨牐x8免费| 九九视频高清视频免费观看| 亚洲视频免费在线看| 日韩免费高清大片在线| 中文字幕一精品亚洲无线一区| 色屁屁www影院免费观看视频| 免费看无码自慰一区二区| 精品人妻系列无码人妻免费视频| 亚洲毛片网址在线观看中文字幕|