Building thead with Array list?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Building thead with Array list?

 items in my table output.
What is the thymeleaf syntax that will allow me to iterate over the name array to ultimately result in something like:
        <thead>
            <tr>
                <th>
                    THead Item One
                </th>
                <th>
                     THead Item Two
                </th>
                <th>
                     THead Item Three
                </th>
            </tr>
        </thead>
given a model object of :
 Arrays.asList("THead Item One", "THead Item Two", "THead Item Three");

?

what do I anchor my : th:each against?
If I do this with the
<tr>
 element, I wind up with three
<tr>
 elements with a separate
<th>
 element in it... which isn't what I want... I want three
<th>
 elements in the one
<tr>
 tag.
How do I do this?
 
karlkras
Hey... so I'd like to provide an Array to my thymeleaf template that describes the
Reply | Threaded
Open this post in threaded view
|

Re: Building thead with Array list?

mkobel
The following code should work:

<thead>
   <tr>
     <th th:each="item : ${itemList}" th:text="${item}"></th>
   </tr>
</thead>