我有这个代码:
private String delete(HttpServletRequest req, HttpServletResponse res, Seller seller) throws Exception {
//check data
if(req.getParameter("equipmentId") == null) {
throw new Exception("equipmentId undefined");
}
//build
Equipment equipment = new Equipment(Integer.parseInt(req.getParameter("equipmentId")));
//delete
dbEquipment.delete(equipment);
//remove in array list
for(int i = 0; i < seller.getListEquipment().size(); i++) {
if(seller.getListEquipment().get(i).getId() == equipment.getId()) {
seller.getListEquipment().remove(i);
}
}
//response
return "ok";
}
传递的卖家属性来自 HTTPSession : ((Seller) req.getSession().getAttribute("user"))
此代码离线更新我的对象卖家很好,但在线更新不显示,它仍然是旧对象/ArrayList。