删除单个
根据下标清除 (remove)
代码
ShoppingAction
Shopping没有实体类,所有业务逻辑以及操作都放在action层里
public String del(HttpServletRequest request, HttpServletResponse response) {
ObjectMapper om = new ObjectMapper();
try {
user currentUser = (user) request.getSession().getAttribute("user");
long uid = currentUser.getId();
String shopId = "shopId_" + uid;
String shopVoStr = (String) request.getServletContext().getAttribute(shopId);
List<ShoppingVo> shopGoodsVos = om.readValue(shopVoStr, List.class);
int index = Integer.valueOf(ShoppingVo.getPageStr());
shopGoodsVos.remove(index);
request.getServletContext().setAttribute(shopId,om.writeValueAsString(shopGoodsVos));
} catch (Exception e) {
e.printStackTrace