获取上下文资源文件中的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;
?}
}