coul wao
coul wao

Reputation: 13

Display an image at the click of a button in thymeleaf java

I want to display an image in the browser from a click of a button.

In my view, I loop over a list that returns to me my controller. For each element of the list I would like to be able to display the image associated with the element. The images are in a folder placed at the root it is in the resources folder.

enter image description here

enter image description here

Upvotes: 1

Views: 403

Answers (1)

Unmitigated
Unmitigated

Reputation: 89314

Use the <img> tag inside th:each.

<img th:src="@{'/photos/' + ${vehicules.image}}"/>

Upvotes: 1

Related Questions