⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 springcontextutils.java

📁 一个自娱自乐的demo 开发环境 apache-tomcat-6.0.16 Mysql 5.1.11 Jdk 1.6 文件结构如下 --MyGame -----MyGam
💻 JAVA
字号:
package com.hb.base.util;

import java.util.Locale;

import javax.faces.context.FacesContext;

import org.springframework.context.ApplicationContext;
import org.springframework.web.jsf.FacesContextUtils;

/**
 * @author 何 貝
 * 
 * Spring 上下文工具类
 * 
 */
public class SpringContextUtils {
	/**
	 * 取得 ApplicationContext
	 * 
	 * @return ApplicationContext
	 */
	public static ApplicationContext getSpringContext() {
		FacesContext facesContext = FacesContext.getCurrentInstance();
		ApplicationContext applicationContext = FacesContextUtils.getWebApplicationContext(facesContext);
		return applicationContext;
	}

	/**
	 * 取得 SpringBean
	 * 
	 * @param beanName bean名称
	 * @return SpringBean
	 */
	public static Object getSpringBean(String beanName) {
		return getSpringContext().getBean(beanName);
	}

	/**
	 * 取得消息资源
	 * 
	 * @param msgKey 消息Key
	 * @param args 消息Param
	 * @param locale Locale
	 * @return
	 */
	public static String getMessage(String msgKey, Object[] args, Locale locale) {
		return getSpringContext().getMessage(msgKey, args, locale);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -