Difference between Thymeleaf include and replace?

According to documentation if you have this situation:

<div th:include="..."> content here </div>

fragment will be placed inside <div> tag.

However when you use replace:

<div th:replace="..."> content here </div>

then <div> will be replaced by content.

Thymeleaf can include parts of other pages as fragments (whereas JSP
only includes complete pages) using th:include (will include the
contents of the fragment into its host tag) or th:replace (will
actually substitute the host tag by the fragment’s).

Leave a Comment