com.hb0730.commons.spring.SpringMessageUtils Maven / Gradle / Ivy
package com.hb0730.commons.spring;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
/**
* spring message i18n
*
* @author bing_huang
* @since 1.0.0
*/
public class SpringMessageUtils {
/**
* 根据消息键和参数 获取消息 委托给spring messageSource
*
* @param code 消息键
* @param args 参数
* @return 获取国际化翻译值
*/
public static String message(String code, Object... args) {
MessageSource messageSource = SpringContextUtils.getBean(MessageSource.class);
return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy