关闭。这个问题需要细节或清晰。它目前不接受答案。
**想改进这个问题吗?**通过编辑这个帖子来添加细节并澄清问题。
21天前关门了。
改进这个问题
我在一个大类对象中有许多类对象的子对象。我已经为这些子对象设置了值,我希望它们通过请求范围打印到我的jsp页面中。如何在jsp中实现这一点?
我的大类对象
public class BookUser implements Serializable {
private Books book;
private Users user;
public BookUser() {
}
public Books getBook() {
return book;
}
public void setBook(Books book) {
this.book = book;
}
public Users getUser() {
return user;
}
public void setUser(Users user) {
this.user = user;
}
}
我的jsp
<c:set var="listBookNew" value="${requestScope.LISTALLBOOKORIGINAL}"/>
<c:if test="${not empty listBookNew}">
<table border="1">
<thead>
<tr>
<th>Id</th>
<th>Title</th>
<th>Price</th>
<th>Quantity</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<c:forEach var="dtoX" items="${listBookNew}">
<tr>
<td>${dtoX.book.id}</td>
<td>${dtoX.book.bookTitle}</td>
<td>${dtoX.book.price}</td>
<td>${dtoX.book.quantity}</td>
<td>${dtoX.book.bookDate}</td>
</tr>
</c:forEach>
</tbody>
</table>
</c:if>
编辑:我输入的requestscope属性名称错误。对不起各位,谢谢大家花时间阅读本文。
1条答案
按热度按时间bjp0bcyl1#
您可以在foreach和tr之间添加c:set,如下所示: