I am using spring boot with thymeleaf. This is my project structure:
![enter image description here](https://i.stack.imgur.com/kI9MH.png)
这是我的应用程序开始课程:
@EnableAutoConfiguration
@Configuration
@ComponentScan
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class);
}
}
我的 home.leaf.html 上有这个:<p th:text = "#{username}"></p>
但是当我运行这个应用程序时,我得到的是:??username_en_US??
我已经尝试了各种方法来解决此配置问题。请问有人可以帮忙吗?
spring boot 参考官方文档
http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-convert-an-existing-application-to-spring-boot
It says
静态资源可以移动到/public
(or /static
or /resources
or
/META-INF/resources
)在类路径根目录中。同样适用于messages.properties
(Spring Boot 会在
类路径的根)。
所以你应该创建你的国际化文件messages.properties
并放置在根类路径中。
或者,您也可以通过添加此条目来将默认位置编辑为更合适的位置application.properties
file
#messages
spring.messages.basename=locale/messages
因此您可以将文件存储在资源文件夹内的区域设置文件夹中,名称为messages.properties
或任何特定语言。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)