Thymeleaf: create a list of elements statically

The following code can be used to statically create a list of elements (numbers, strings, etc) inside a Thymeleaf view.

A list of integers:

intList = ${ {1, 2, 3, 4} }

A list of strings:

strList = ${ {'netgloo', 'web', 'design'} }

Usage example

<div th:with="strList = ${ {'netgloo', 'web', 'design'} }">

  <!-- Some code using ${strList} -->
    <li th:each="s : ${strList}" th:text="|${s}|"></li>



Category BootstrapCategory CoffeescriptCategory DrupalCategory GravCategory HTMLCategory JavascriptCategory JoomlaCategory jQueryCategory LaravelCategory MagentoCategory PHPCategory SharePointCategory SpringCategory ThymeleafCategory WordPressCategory Workflow


Developed and designed by Netgloo
© 2016 Netgloo