TblUser 实体:
@Id
@Basic(optional = false)
@Column(name = "hotelID", nullable = false)
private Integer hotelID;
@Basic(optional = false)
@Column(name = "hotelName", nullable = false, length = 50)
private String hotelName;
@Basic(optional = false)
@Column(name = "addess", nullable = false, length = 250)
private String addess;
@Basic(optional = false)
@Column(name = "description", nullable = false, length = 250)
private String description;
@Basic(optional = false)
@Column(name = "services", nullable = false, length = 250)
private String services;
@Column(name = "starLevel")
private Integer starLevel;
@Column(name = "phone", length = 20)
private String phone;
@Column(name = "isMain")
private Boolean isMain;
@JoinColumn(name = "Owner", referencedColumnName = "userID")
@ManyToOne
private TblUser owner;
@OneToMany(mappedBy = "hotelAgent")
private Collection<TblHotel> tblHotelCollection;
@JoinColumn(name = "hotelAgent", referencedColumnName = "hotelID")
@ManyToOne
private TblHotel hotelAgent;
这是show.jsp
<c:set var="result" value="${requestScope.RESULT}"/>
<c:if test="${not empty result}">
<c:forEach var="row" items="result">
The main hotel Name: ${row.hotelName}
Address: ${row.address}
Phone: ${row.phone}
Star Level: ${row.starLevel}
<table border="1">
<thead>
<tr>
<th>No</th>
<th>hotelName</th>
<th>addess</th>
<th>description</th>
<th>services</th>
<th>starLevel</th>
<th>phone</th>
<th>Owner</th>
</tr>
</thead>
<tbody>
<c:forEach var="rows" items="${row.tblHotelCollection}" varStatus="counter">
<tr>
<td>${counter.count}</td>
<td>${rows.hotelName}</td>
<td>${rows.addess}</td>
<td>${rows.description}</td>
<td>${rows.services}</td>
<td>${rows.starLevel}</td>
<td>${rows.phone}</td>
<td>${rows.Owner}</td>
</tr>
</c:forEach>
</tbody>
</table>
</c:forEach>
我的课程是公开的,所有 getter setter 都是实施的。我的库是 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>,没关系。我花了几个小时,但不知道什么是错误。