I have collection X
I iterate through it and write it like that:
<span th:each="a, stat : ${X}"
th:text="${X[__${stat.index}__].someProperty} + ','">
</span>
my other try was:
<span th:each="a, stat : ${X}" th:for="|a${stat.index}|"
th:text="${X[__${stat.index}__].someProperty} + ','">
</span>
unfortunately the output is the same.
the output in the span is:
test1, test2, test3,
I want the output to be:
test1, test2, test3
without the comma at the end. How can I achieve that?
Solution:
- Beware of The value of attribute
th:textassociated with an element typespanmust not contain the '<' character.
Code:
<span th:each="a, stat : ${X}"
th:text=" ${X[__${stat.index}__].someProperty} + (${stat.size-1 > stat.index}? ',':'') ">
</span>