Spring學習心得(四)

           

           

           

           

          Spring學習心得(四)

          1.       SpringStruts連接:為了在Struts中使用Spring ,需要在Strutscongfig中加入

          <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">

                  <set-property property="contextConfigLocation"

                      value="/WEB-INF/applicationContext.xml"/>

              </plug-in>

          2.       對于actionSpring的應用有兩種方法:

          a)       Extends ActionSupport,使用其中的getWebApplicationContext()得到ApplicationContext,在通過getBean()方法得到所需要的類,不過這樣的話Struts就和Spring耦合在一起了。

          b)      重新Delegating actions :在Strutscongfig進行配置:

          <action path="/XXXX"

          type="org.springframework.web.struts.DelegatingActionProxy"/>

          然后在Spring中進行bean的配置:

          <bean name="/XXXX"

          這里為需要用到的class,通過Ioc來進行配置

          class="XXXXXXXX">

          <property name="YYYY">

          <ref bean="YYYY"/>

          </property>

          </bean>

          <bean id="YYYY" class="YYYYYY">

          </bean>

          當然也可以在struts中加入

          <controller processorClass=

          "org.springframework.web.struts.DelegatingRequestProcessor"/>

          這樣就只需要寫

          <action path="/XXXX"/>就可以了,DelegatingRequestProcessor能夠自動分派

           

          posted on 2007-09-05 10:21 劉錚 閱讀(287) 評論(0)  編輯  收藏 所屬分類: Spring

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導航

          統計

          留言簿(1)

          文章分類(141)

          文章檔案(147)

          搜索

          最新評論

          主站蜘蛛池模板: 大英县| 互助| 花莲市| 广西| 宁化县| 堆龙德庆县| 吴川市| 策勒县| 合肥市| 金山区| 宣恩县| 仁布县| 从化市| 安宁市| 青川县| 贵州省| 会东县| 遵义市| 云安县| 扬州市| 财经| 玛纳斯县| 襄汾县| 峨边| 钟祥市| 五寨县| 潼关县| 扎兰屯市| 乌拉特中旗| 静乐县| 大渡口区| 岳阳县| 榆中县| 榆树市| 常熟市| 永泰县| 蛟河市| 普兰店市| 瓦房店市| 尚志市| 黄梅县|