日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

小结spring和struts整合的三类方式

發(fā)布時間:2025/4/16 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 小结spring和struts整合的三类方式 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
小結(jié)spring和struts整合的三類方式

? 整合spring和hibernate的三種方式,小結(jié)之.

?

1) 在struts中使用webapplicationcontext調(diào)用spring
??? 聲明web.xml,聲明一個contextloadlistener,讓在啟動時執(zhí)行該listener,讀spring的配置文件

??? <listener>
??<listener-class>
???org.springframework.web.context.ContextLoaderListener
??</listener-class>
?</listener>

? 再增加一個contextConfigLocation
?? <context-param>
??<param-name>contextConfigLocation</param-name>
??<param-value>/WEB-INF/applicationContext*.xml</param-value>
?</context-param>

?WebApplicationContext ctx=WebApplicationContextUtils.getWebApplicationContext(servletContext);

? UserBean userbean=(UserBean)ctx.getBean("userbean");

?

2) 將struts的action托管給spring
?????? 這也是很經(jīng)常用的.用法是
??? 在struts-config.xml中,加載contextloaderplugin插件,加載spring配置

?

<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />


??<plug-in
??className="org.springframework.web.struts.ContextLoaderPlugIn">
??<set-property property="contextConfigLocation"
??value="/WEB-INF/applicationContext.xml" />
??</plug-in>

? 這樣的話,把struts的action完全托管給spring了,在struts-config.xml中

??? <action path="/user/"..>,這里不需要再用class了,

但在application-context.xml中,則要有
?? <bean name="/user"..../>了.

?

3 繼承spring的actionsupport類
????? 比如

?? public class aaaa extends DispatchActionSupport

?{

??????? ......

?

????????WebApplicationContext ctx=WebApplicationContextUtils.getWebApplicationContext(servletContext);

? UserBean userbean=(UserBean)ctx.getBean("userbean");

?

?

?

?? }
???

?


???

posted on 2008-08-27 21:22 jackyrong的世界 閱讀(...) 評論(...) 編輯 收藏

轉(zhuǎn)載于:https://www.cnblogs.com/jackyrong/archive/2008/08/27/1278056.html

總結(jié)

以上是生活随笔為你收集整理的小结spring和struts整合的三类方式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。