【发布时间】:2016-09-01 08:30:33
【问题描述】:
Thymeleaf 2.14 版正在正确获取 message.properties 文件。迁移到 3.0 后,出现错误 ??hello.MESSAGE_en_US??。 但是在javacode中通过自动装配messagesource
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
配置
@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
resourceBundleMessageSource.setBasename("messages");
resourceBundleMessageSource.setBasename("spring");
return resourceBundleMessageSource;
}
【问题讨论】:
标签: spring spring-mvc thymeleaf properties-file