Thymeleaf版本2.14正确地提取message.properties文件。迁移到3.0之后,它给出了错误?? hello.MESSAGE_en_US ??。 但在javacode通过自动装配messsagesource将thymeleaf版本2.14迁移到3.0找不到消息属性
messageSource.getMessage("hello.MESSAGE",null, Locale.getDefault()) ->Hello App
项目结构
src/main/
-java
-com.cando
-controllers
-resources
-messages_en.properties
-spring.properties
-webapp
-WEB-INF
-templates
-index.html
的index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Helllo</title>
</head>
<body>
<p th:text="#{hello.MESSAGE}">Hello App!</p>
</body>
</html>
messages_en.properties
hello.MESSAGE=Hello App
CONFI摹
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
resourceBundleMessageSource.setBasename("messages");
resourceBundleMessageSource.setBasename("spring");
return resourceBundleMessageSource;
}
使用setBasenames( “信息”, “春”),但问题尝试没有解决 –