Configured Spring for internalization and localization, but ran into a problem in the encoding. English characters are displayed normally, but instead of the Russian text question marks ??????? . Configuration Code:

 @Bean public LocaleResolver localeResolver(){ CookieLocaleResolver resolver = new CookieLocaleResolver(); resolver.setDefaultLocale(new Locale("ru")); resolver.setCookieName("locale"); resolver.setCookieMaxAge(60 * 60 * 24 * 365 * 10); return resolver; } @Bean public MessageSource messageSource() { ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setBasename("classpath:/i18n/messages"); messageSource.setDefaultEncoding("UTF-8"); messageSource.setFallbackToSystemLocale(true); return messageSource; } @Override public void addInterceptors(InterceptorRegistry registry) { LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor(); localeChangeInterceptor.setParamName("lang"); registry.addInterceptor(localeChangeInterceptor); } 

I also use Thymeleaf:

 <h1 th:text="#{message}"></h1> 

    1 answer 1

    The *.properties must be saved in the same encoding as specified in the MessageSource .