Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. In your HTML template, define your source DTO and target DTO as Thymeleaf variables using th:object attribute.

Example:

<div th:object="${sourceDTO}" th:with="targetDTO=${new targetDTO()}">
  1. Use Thymeleaf expression syntax to transfer values from the source DTO to the target DTO.

Example:

<input type="text" th:value="${sourceDTO.name}" th:field="*{name}">

In this example, the value of the "name" property in the sourceDTO is transferred to the "name" property in the targetDTO.

  1. Use Thymeleaf expression syntax to display the values of the target DTO in your HTML template.

Example:

<p th:text="${targetDTO.name}"></p>

In this example, the value of the "name" property in the targetDTO is displayed in a paragraph element in the HTML template.