日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

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

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

?

1) 在struts中使用webapplicationcontext調用spring
??? 聲明web.xml,聲明一個contextloadlistener,讓在啟動時執行該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
?????? 這也是很經常用的.用法是
??? 在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的世界 閱讀(...) 評論(...) 編輯 收藏

轉載于:https://www.cnblogs.com/jackyrong/archive/2008/08/27/1278056.html

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。