Reputation: 153
I want to convert the following link in my jsp file to thymeleaf :
<c:forEach items="${users}" var="user">
<tr>
<td>
<a href='<spring:url value="/users/${user.id}" />'>
${user.name}
</a>
</td>
</tr>
</c:forEach>
like this :
<tbody>
<tr th:each="user : ${users}">
<td th:text="${user.name}"><a href="/users"
th:href="@{/users(id=${user.id})}" >user name</a></td>
</tr>
</tbody>
but it doesn't function, can someone point me in the right direction?
Upvotes: 1
Views: 205
Reputation: 153
I solved my own problem referring to usingthymeleaf it might be useful for someone else, this code generates what I was looking for: /users/3 where 3 is the {id}
<tbody>
<tr th:each="user : ${users}">
<td ><a th:text="${user.name}"
href="/users" th:href="@{'/users/' + ${user.id}}" >user name</a></td>
</tr>
</tbody>
Upvotes: 2