How to include message.properties with thymeleaf
Refer the official documentation for spring boot
It says
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).
So you should create ur internationalization file as messages.properties
and place in the root classpath.
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
so you can store your files in the locale folder inside resources folder, with the name messages.properties
or in any specific language.
Related videos on Youtube
osagie
Updated on June 30, 2022Comments
-
osagie almost 2 years
I am using spring boot with thymeleaf. This is my project structure:
And this is my App start class:
@EnableAutoConfiguration @Configuration @ComponentScan public class App { public static void main(String[] args) { SpringApplication.run(App.class); } }
I have this on my home.leaf.html:
<p th:text = "#{username}"></p>
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?
-
Pedro Affonso about 9 yearsLooks like you need to configure your message source (set the directory where spring will look for messages.properties)
-
M. Deinum about 9 yearsRename
message.properties
tomessages.properties
.
-