Search code examples
thymeleaf

Thymeleaf put a dynamic parameter inside script tag


With thymeleaf and following code

<script th:src="@{/js/init.js}"></script>

I would like to make it like following in order to avoid browser caching for this file

<script th:src="@{/js/init.js?${minute}}"></script>

${minute} will be current time minute.


Solution

  • Try:

    <script th:src="@{/js/init.js(minute=${minute})}"></script>
    

    Reference: Standard URL Syntax