0

In a html file, I am trying to get the fields and values in the following DTO using Thymeleaf:

ValuesDTO(serving=100.0, unit=G, energy=160.0, protein=5.0, totalFat=7.0)

So, how can I list values as the following? The labels are static, I just need to get the corresponding value by field name e.g. energyAmount

Energy: 160.0    --> get value of `energy` field
Protein: 5.0     --> get value of `protein` field
Total Fat: 7.0     --> get value of `totalFat` field
  • 1
    Can you show the html/thymeleaf code where you want to integrate it and the Java code where you set the attribute? – dan1st Aug 23 '22 at 20:50
  • Do you really need to parse that comma-separated string? Or is that just the `toString()` result of a `ValuesDTO` Java object? – Wim Deblauwe Aug 24 '22 at 06:05

0 Answers0