Closed John-Chan closed 7 years ago
Test code
@Configuration class ResourceConfig { private static final String MESSAGE_SOURCE = "/i18n/messages"; @Bean(name = "messageSource") public MessageSource messageSource() { ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setBasename(MESSAGE_SOURCE); //messageSource.setDefaultEncoding("UTF-8"); messageSource.setCacheSeconds(5); return messageSource; } } @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {ResourceConfig.class} ) public class TestMessageSource { @Resource(name = "messageSource") private MessageSource messageSource; @Test public void testGetMessageCN(){ final String MSG_KEY = "hello.message"; String[] para={"john","www.example.com"}; String msgCN= messageSource.getMessage(MSG_KEY, para, new Locale("zh", "CN")); } }
The encoding of msgCN is not correct unless call messageSource.setDefaultEncoding("UTF-8");
msgCN
Fixed. Released in 1.0.1. Thanks!
Test code
The encoding of
msgCN
is not correct unless call messageSource.setDefaultEncoding("UTF-8");