CortezDaCardinal
CortezDaCardinal

Reputation: 35

how to assign thymeleaf variable to a tag value

<c:forEach var="item" items="${list}" >
    <option value="${item}"> something </option>
</c:forEach>

How can i do this in thymeleaf?

I've tried something like this:

<option th:each="item:${list}" value="${item}">  some product $ </option>

but it uses ${item} like a simple text "${item}".

Upvotes: 0

Views: 1243

Answers (1)

mixiul__
mixiul__

Reputation: 405

Have you tried this:

<option th:each="item:${list}" th:value="${item}">  some product $ </option>

You may just be missing the th: prefix for the value attribute.

Upvotes: 1

Related Questions