首页 > 移动平台 > 详细

sp启动后获取ApplicationContext 对象的方法

时间:2014-03-16 05:03:31      阅读:569      评论:0      收藏:0      [点我收藏+]

 


import java.util.Locale;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

@Service
public class SpringUtil implements ApplicationContextAware {
public static ApplicationContext appContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
appContext = applicationContext;
}
public static String getMessage(String key, Object... params) {
return getMessage(key, params, Locale.ENGLISH);
}
public static String getMessage(String key,Object[] params,Locale locale) {
return appContext.getMessage(key, params, locale);
}

http://bbs.22cg.com/forum-113-1.html
http://bbs.22cg.com/forum-111-1.html
tcc55.com
70ky.com
http://flash.22cg.com/baoshijieyulecheng/
http://flash.22cg.com/yingfengguojiyulecheng/


public static Object getBean(String serviceName){
Object obj = new Object();
try {
obj = SpringUtil.appContext.getBean(serviceName);
} catch (BeansException e) {
e.printStackTrace();
return null;
}
return obj;
}
}

sp启动后获取ApplicationContext 对象的方法,布布扣,bubuko.com

sp启动后获取ApplicationContext 对象的方法

原文:http://www.cnblogs.com/geziwu/p/3600778.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!