这段代码报了上面的异常:Property 'items' not found on type com.bookstore.domain.ShoppingCart
但是同样的EL表达式操作同一个类的字段就没问题:${sessionScope.ShoppingCart.bookNumber }
<c:forEach items="${sessionScope.ShoppingCar.items}" var="item">
<tr>
<td>${item.book.title }</td>
<td>${item.book.price }</td>
<td>${item.quantity }</td>
<td><a href="">删除</a></td>
</tr>
</c:forEach>
后来百度了好久uemei找到答案,看到一个博客上把EL表达式写成这样:${sessionScope[username] }
于是试着把自己的也改了:
<c:forEach items="${sessionScope[ShoppingCart[items]]}" var="item">
居然可以正常运行了。!!