Spring MVC: Show Data In A Table Row?
I am trying to display data in a table row. However it is just showing the var name as output, e.g: Name | age User1| {age} I am using Spring-MVC along with Spring Boot. I have cr
Solution 1:
Try this :
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>User 1</td>
<td th:text="${age}"> Age </td>
</tr>
</table>
If you have a list of age like this:
List<Integer> listOfAge = new ArrayList<>(Arrays.asList(23,45,45,23,54,23,43));
model.addAttribute("listOfAge", listOfAge);
then try this:
<table>
<tr>
<th>Sr. No</th>
<th>Name</th>
<th>Age</th>
</tr>
<tr th:each="age,iterationstatus :${listOfAge}">
<td th:text="${iterationstatus.count}">1</td>
<td>User 1</td>
<td th:text="${age}"> Age </td>
</tr>
</table>
Post a Comment for "Spring MVC: Show Data In A Table Row?"