Thymeleaf placeholder in input type="text"

html, thymeleaf

Solution

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}" />

Problem

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}"" /> ```

Original source