使用Spring Framework中的MessageSource实现国际化消息。
示例代码:
    org.springframework 
    spring-context 
    5.2.9.RELEASE 
 
     
 
在resources目录下创建messages.properties文件,包含键值对,例如:
welcomeMsg=欢迎使用我们的应用程序!
@Autowired
private MessageSource messageSource;
String welcomeMsg = messageSource.getMessage("welcomeMsg", null, Locale.getDefault());
其中,“welcomeMsg”是属性文件中的键,第二个参数传入的是参数数组,第三个参数传入的是区域设置,默认为系统默认值。getMessage方法返回对应的消息字符串。