Search code examples
spring-bootthymeleaf

how to simplify <img src="img/java.jpg" th:src="@{'img/'+${book.image}}" height="60"/>


I'm new to SpringBoot, The whole code of html is here

My question is:

Is there a way to simplify this code:

<img src="img/java.jpg" th:src="@{'img/'+${book.image}}" height="60"/>

the java.jpg is already contained in book.image.

Thanks for your help.


Solution

  • You can remove the src attribute. This is anyway not rendered by thymeleaf

    <img th:src="@{'img/'+${book.image}}" height="60"/>