I have this input text in a
<input type="text" id="usernameId" name="username" placeholder="User" />
I want to replace the text of the placeholder User for 1 text from the properties file, but I don't know if it is possible
<input type="text" id="usernameId" name="username" placeholder="th:text="#{user.placeholder}"" />
There is a specific Thymeleaf attribute for that:
<input type="text" id="usernameId" name="username" th:placeholder="#{user.placeholder}" />
It can also be written like this:
<input type="text" id="usernameId" name="username" th:attr="placeholder=#{user.placeholder}" />
In the above answer it should be
<input type="text" id="usernameId" name="username" th:placeholder="${user.placeholder}" />
${...} operator is for using with objects in context such as request, session and objects set in model.
#{...} operator is for message expressions..
Check thymeleaf tags list and thymeleaf doc for details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With