Search code examples
spring-bootthymeleafspring-thymeleaf

Thymeleaf: index.html page did not display correctly after upgrade Sprint Boot from 1.4.3 to 1.5.22


Recently, I started trying to upgrade an application in SpringBoot with Thymeleaf (from 1.4.3 to 1.5.22). The application started fine, but when I checked those html pages, none of them display correctly. After looking into more details, I found that in the index.html was missing something.

The following are shown portion of the index.html from both versions after Thymeleaf transformation.

link rel="icon" th:href="@{/static/console/img/favicon.ico}" type="image/x-icon"

View source page in version 1.4.3 link rel="icon" type="image/x-icon" href="/dev/static/console/img/favicon-e58edb9fec1d2c653aac22892a890626.ico"

View Source page in version 1.5.22 link rel="icon" type="image/x-icon" href="/static/console/img/favicon.ico"

It seems that href and src attributes are missing the suffix jsession id. Can anyone know what I need to do to correct that?


Solution

  • When the icon is in src/main/resources/static/console/img, then use the following in your Thymeleaf template: th:href="@{/console/img/favicon.ico}"

    (So static should not be in the path if you reference it from Thymeleaf.)