i have problem with display my items from database. I assign my item object to ArrayList and want to display it in html file, every time when I try display it, i have Whitelabel Error Page. When i display this code below its worked but iteration not.
HTML:
<span th:text="${item.get(0).getItemName()}"></span>
^ working
<tr th:each="person, state : ${item}" class="row" th:classappend="${state.odd} ? 'odd-row' : 'even-row'">
<td th:utext="${item.getItemName()}">Full Name</td>
</tr>
^ Not working
Java:
List<item> item = new ArrayList<>();
itemRepository.findAll().forEach(item::add);
List<item> findList = new ArrayList<item>();
for (int i = 0; i < item.size(); i++) {
if(item.get(i).getWhoAdd().equals(isExist.getId())){
findList.add(item.get(i));
}
}
model.addAttribute("item",findList);
return "item";
In the code sample you have shown as not working, try using the following
<td th:text="${person.getItemName()}">Full Name</td>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.