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

获取前后文资源文件中的value值-ResourceUtil.java

2013-10-16 
获取上下文资源文件中的value值--ResourceUtil.javaResourceUtil.javapackage com.mycompany.appcore.util

获取上下文资源文件中的value值--ResourceUtil.java

ResourceUtil.java

package com.mycompany.appcore.utils;

import java.util.Locale;

import javax.annotation.Resource;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@Service
public class ResourceUtil {

?@Resource
?private ApplicationContext applicationContext;

?public String getMessage(String key) {
??return applicationContext.getMessage(key, new Object[0], null);
?}

?public String getMessage(String key, Locale locale) {
??return applicationContext.getMessage(key, new Object[0], locale);
?}

?public String getMessage(String key, Object[] args) {
??return applicationContext.getMessage(key, args, null);
?}

?public String getMessage(String key, Object[] args, Locale locale) {
??return applicationContext.getMessage(key, args, locale);
?}

?public ApplicationContext getApplicationContext() {
??return applicationContext;
?}

?public void setApplicationContext(ApplicationContext applicationContext) {
??this.applicationContext = applicationContext;
?}
}

热点排行