1

I have a message.properties in my Spring Boot program and it works fine with Thymeleaf in HTML templates. However, I want to use key=value also in Java code. For example, I have:

public static final String PDF_PROGRAM_INFO_FIRST_LINE = "Some text"

In message.properties, I have:

text = Some text

How to put key into my string in code to use it value instead of typing string by hand?

I tried:

public static final String PDF_PROGRAM_INFO_FIRST_LINE =("${text}")

However, this doesn't work.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Rancorec
  • 11
  • 3
  • you can find your solution here : https://stackoverflow.com/questions/46659679/spring-boot-application-and-messagesource – Tony Keith Feb 16 '21 at 14:13
  • Thank you. Is it possible to do it in Spring boot without creating extra beans ? In Thymeleaf it works without any extra configuration (only using th:text="#{text}" ) hence i think springboot got my message.properties already in context. – Rancorec Feb 16 '21 at 14:28

0 Answers0