package com.nanometer.smartlab.util; import com.nanometer.smartlab.service.SmartLabSpringContext; import org.springframework.context.support.ResourceBundleMessageSource; /** * Created by johnny on 17/6/12. */ public class MessageUtil { private static ResourceBundleMessageSource messageSource = null; public static String getMessage(String key) { return getMessage(key, null); } public static String getMessage(String key, Object... values) { if (messageSource == null) { messageSource = (ResourceBundleMessageSource) SmartLabSpringContext.getBean("messageSource"); } String s = messageSource.getMessage(key, values, null); return s; } public static String getMessageByCode(String code , Object... values) { String key = "code_" + code; return getMessage(key, values); } public static String getMessageByCode(String code) { return getMessageByCode(code, null); } }