struts2中使用Spring 外掛程式(一)

2021-08-30 12:11:40 字數 961 閱讀 9147

1、 整合 spring 的準備工作:

1.1 、 把spring.jar 、 commons-logging.jar 、 struts2-spring-plugin-***.jar 複製到 lib 中;

1.21.2.1 、對於 servlet2.3 以後的版本,可以通過 listener 的方式載入,方法如下:

org.springframework.web.context.contextloaderlistener

先確定多個配置檔案 à

引數名為 contextconfiglocation à

contextconfiglocation

/web-inf/acontext.xml,/web-inf/bcontext.xml

採用 listener 完成 spring 容器的初始化 ->

org.springframework.web.context.contextloaderlistener

1.2.2 、對於 servlet2.3 之前的版本,使用 load-on-startup servlet 進行載入

同樣,有兩種情況:

( 1 )、乙個配置檔案的:

context 

org.springframework.web.context.contextloaderservlet 1

( 2 )、多個配置檔案的情況:

引數名為 contextconfiglocation à

contextconfiglocation

/web-inf/acontext.xml,/web-inf/bcontext.xml

採用 load-on-startup servlet 完成 spring 容器的初始化 ->

context 

org.springframework.web.context.contextloaderservlet 1

myeclipse中使用struts2的配置

好了,說今天更新就今天更新,絕不拖拉,hhh.好吧,其實我也是弄了蠻久才知道 struts2 到底有什麼用,感覺之前的一些東西用來做開發足矣,並且也沒有什麼不合理的地方,找了很久的資料才又回憶起一點點,上課的東西兩天沒看就差不多都還給老師了,做的筆記也看不懂了,說正事。struts2 到底用起來有什...

在Struts2中使用SiteMesh外掛程式

最近在讀 struts2權威指南 李剛著 這本書寫得非常好,對我學習struts2幫助很大。在學習這本書的過程中,我自己做了些筆記和例子,下面是關於在struts2中如何使用sitemesh外掛程式 通過使用sitemesh外掛程式,就可以在struts2應用中使用sitemesh裝飾器頁面來統一應...

struts2 中使用 servlet遇到的問題

這幾天一直被乙個問題困擾,我想在struts2中使用servlet可是一直出現404 找不到servlet的錯誤 今天終於找到了原因,因為我的struts過濾器過濾了所有請求,我的web.xml是這樣配置的 struts2 org.apache.struts2.dispatcher.filterdi...