Spring獲取ApplicationContext對(duì)象工具類的實(shí)現(xiàn)方法
Spring獲取ApplicationContext對(duì)象工具類的實(shí)現(xiàn)方法
(1)實(shí)現(xiàn)的工具類:
package com.util; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; final public class ApplicationContextUtil { private static ApplicationContext ac=null; private ApplicationContextUtil(){ } static{ ac=new ClassPathXmlApplicationContext("applicationContext.xml"); } public static ApplicationContext getApplicationContext(){ //獲得返回的容器對(duì)象 return ac; } }
(2)使用方法:
public static void getByUtil(){ ApplicationContextUtil.getApplicationContext().getBean("userService"); }
如有疑問請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
上一篇:jsp 使用request為頁面添加靜態(tài)數(shù)據(jù)的實(shí)例
欄 目:JSP編程
本文標(biāo)題:Spring獲取ApplicationContext對(duì)象工具類的實(shí)現(xiàn)方法
本文地址:http://mengdiqiu.com.cn/a1/JSPbiancheng/11448.html
您可能感興趣的文章


閱讀排行
本欄相關(guān)
- 01-11web下載文件和跳轉(zhuǎn)的方法
- 01-11Spring注入Date類型的三種方法總結(jié)
- 01-11在JSP中使用formatNumber控制要顯示的小
- 01-11Properties 持久的屬性集的實(shí)例詳解
- 01-11EJB3.0部署消息驅(qū)動(dòng)Bean拋javax.naming.Na
- 01-11jsp文件下載功能實(shí)現(xiàn)代碼
- 01-11JSP頁面跳轉(zhuǎn)方法大全
- 01-11詳解Spring的核心機(jī)制依賴注入
- 01-11jsp 使用request為頁面添加靜態(tài)數(shù)據(jù)的實(shí)
- 01-11Spring獲取ApplicationContext對(duì)象工具類的
隨機(jī)閱讀
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 01-11ajax實(shí)現(xiàn)頁面的局部加載
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 04-02jquery與jsp,用jquery
- 01-10C#中split用法實(shí)例總結(jié)
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 01-10delphi制作wav文件的方法
- 01-10使用C語言求解撲克牌的順子及n個(gè)骰子