首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

spring经过ApplicationContext读取Bean、message实例

2012-10-30 
spring通过ApplicationContext读取Bean、message实例1、读取Bean的应用?ServletContext application getSe

spring通过ApplicationContext读取Bean、message实例

1、读取Bean的应用

?

ServletContext application = getServletContext();   // 读取SPRING 容器ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(application);// 读取容器中的QUARTZ总管类org.quartz.Scheduler scheduler = (org.quartz.impl.StdScheduler)ctx.getBean("startQuertz");

?2、读取国际化的应用

Object[] obj = new Object[]{}; Locale locale = (Locale)request.getSession().getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME);ServletContext servletContext = request.getSession().getServletContext();ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);String iString = ctx.getMessage(code, obj, locale);
?

热点排行