雷火电竞-中国电竞赛事及体育赛事平台

歡迎來到入門教程網(wǎng)!

JSP編程

當(dāng)前位置:主頁 > 網(wǎng)絡(luò)編程 > JSP編程 >

Spring獲取ApplicationContext對象工具類的實(shí)現(xiàn)方法

來源:本站原創(chuàng)|時間:2020-01-11|欄目:JSP編程|點(diǎn)擊:

 Spring獲取ApplicationContext對象工具類的實(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(){ 
    //獲得返回的容器對象 
    return ac; 
  } 
   
} 

(2)使用方法:

public static void getByUtil(){ 
    ApplicationContextUtil.getApplicationContext().getBean("userService"); 
  }  

如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

上一篇:jsp 使用request為頁面添加靜態(tài)數(shù)據(jù)的實(shí)例

欄    目:JSP編程

下一篇:JSP頁面跳轉(zhuǎn)方法大全

本文標(biāo)題:Spring獲取ApplicationContext對象工具類的實(shí)現(xiàn)方法

本文地址:http://www.jygsgssxh.com/a1/JSPbiancheng/11448.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有