Which Thymeleaf attribute is used to set the value of an input field?
A)
th:valueB)
th:textC)
th:fieldD)
th:dataAnswer:
A)
th:valueExplanation:
The th:value attribute in Thymeleaf is used to set the value of an input field dynamically. This attribute binds the value of the input field to a model attribute, making it easy to populate forms with existing data.
For example:
<input type="text" th:value="${user.name}" />
In this example, the th:value attribute sets the value of the input field to the name property of the user object.