java如何使用c:foreach列出另一个类中的对象列表。
我的一个对象中有另一个对象的列表。我怎样才能把超人名单拿出来。任何想法或帮助都将不胜感激。谢谢
<table id="contactTable" class="table table-hover" >
<tr>
<th width="10%">Date</th>
<th width="10%">Supers</th>
<th width="50">Location Seen</th>
<th width="20%"></th>
<th width="30%"></th>
</tr>
<tr>
<td>
Date: <c:out value="${sighting.date}"/>
</td>
<td>
Super Person: <c:out value="${sighting.superPerson.name}"/>
</td>
<td>
Location: <c:out value="${sighting.location.locationName}"/>
</td>
</table>
//class
public class Sighting {
private int sightingId;
private String sighting;
private String description;
@DateTimeFormat(iso = ISO.DATE)
private LocalDate date;
private Location location;
private List<SuperPerson> superPerson = new ArrayList<>();
# 1 楼答案
可以使用jstl forEach标记
这里 https://beginnersbook.com/2013/11/jstl-cforeach-and-cfortokens-core-tags/