model.addAtribute(spring,mvc)出现问题



我在对象中有对象(obj CartItem(qunatity,obj Product(中的obj Product(id,name price((,我应该如何将atributes添加到jsp?现在我有这样的东西,TomCat给了我execation[org.apache.jaster.JasperException:处理过程中发生异常]

@PostMapping(path = "/showCart", produces = "text/html; charset=UTF-8")
public String showCart(Model model) {
List<CartItem> cartItems = cart.getCartItems();

model.addAttribute("cartItems", cartItems);
return "showCart";
}

JSP:

<c:forEach items="${cartItems}" var="cartItem">
<tr>
<td>${cartItem.getProduct.id}</td>
<td>${cartItem.getProduct.name}</td>
<td>${cartItem.getProduct.price}</td>
<td>${cartItem.quantity}</td>
<button name="remove" type="submit" value="${cartItem.getProduct.id}">REMOVE</button>
</tr>
</c:forEach>

代码还没有完成,但我首先需要解决这个问题。如果有任何提示,我将不胜感激。

使用字段名称(例如cartItem.product.id(而不是getter名称

最新更新