How to access values in the model in Thymeleaf?

In Thymeleaf, you can access values in the model by using ${} expressions. Here are some examples:

  1. Retrieve the string value:
  2. Display the value from the model.
  3. This will display the string value of the modelValue in the tag.
  4. Accessing object property values:
  5. Display the value of the property in the model.
  6. This will display the value of the property property of the object named modelObject in the tag.
  7. Use the built-in iteration variable of Thymeleaf to iterate over a collection.
  8. For each item in the modelList, display the item in a list item element.
  9. Each element from the collection named modelList in the model will be displayed in an unordered list.

Please make sure that the values in the model are set in the controller before using Thymeleaf to retrieve them.

bannerAds