如何在胸腺中包含message.properties [英] How to include message.properties with thymeleaf
问题描述
我正在与百里香一起使用弹簧靴.这是我的项目结构:
I am using spring boot with thymeleaf. This is my project structure:
这是我的App入门班:
And this is my App start class:
@EnableAutoConfiguration
@Configuration
@ComponentScan
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class);
}
}
我在home.leaf.html上有此文件:< p th:text =#{username}"></p>
I have this on my home.leaf.html: <p th:text = "#{username}"></p>
但是当我运行此应用程序时,我得到的是:"username_en_US"
But when I run this application this is what I get: ??username_en_US??
我已经尝试过各种方法来解决此配置问题.拜托,有人可以帮忙吗?
I have tried various things on how to resolve this configuration issue. Please, can anyone help?
推荐答案
请参阅Spring Boot的官方文档
Refer the official documentation for spring boot
说
静态资源可以移动到
/public
(或/static
或/resources
或类路径根目录中的/META-INF/resources
).相同的messages.properties
(Spring Boot会在类路径的根).
Static resources can be moved to
/public
(or/static
or/resources
or/META-INF/resources
) in the classpath root. Same formessages.properties
(Spring Boot detects this automatically in the root of the classpath).
因此,您应该将您的国际化文件创建为 messages.properties
并放置在根类路径中.
So you should create ur internationalization file as messages.properties
and place in the root classpath.
或者您也可以通过在 application.properties
文件
Or you can also edit the default location to a more proper location by adding this entry in the application.properties
file
#messages
spring.messages.basename=locale/messages
因此您可以将文件存储在resources文件夹内的locale文件夹中,其名称为 messages.properties
或任何特定的语言.
so you can store your files in the locale folder inside resources folder, with the name messages.properties
or in any specific language.
这篇关于如何在胸腺中包含message.properties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!