Tag: 属性文件

将thymeleaf版本2.14迁移到3.0不能找到消息属性

Thymeleaf版本2.14正确拾取message.properties文件。 迁移到3.0之后,它给错误了hello.MESSAGE_en_US ??。 但在javacode通过自动装配messsagesource 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; }