没装工具,随手写一下。
//获得商品id
String strId = request.getpara..("productId");
int id = Integer.paserInt(strid);
//是否存在购物车
if(session.getAtu...("card") == null) {
session.setAtt...("card",new HashMap());
}
//拿出购物车中商品
Map products = (Map)session.getAtt..("card");
//检查商品是否已经存在于购物车
Product pro = products.get(id);
//不存在从数据库中查
if(pro == null){
Product product = new DAO().getProductByid(id);
map.put(id,product);
} else {
//存在就数量+1
}大概是这样吧
//获得商品id
String strId = request.getpara..("productId");
int id = Integer.paserInt(strid);
//是否存在购物车
if(session.getAtu...("card") == null) {
session.setAtt...("card",new HashMap());
}
//拿出购物车中商品
Map products = (Map)session.getAtt..("card");
//检查商品是否已经存在于购物车
Product pro = products.get(id);
//不存在从数据库中查
if(pro == null){
Product product = new DAO().getProductByid(id);
map.put(id,product);
} else {
//存在就数量+1
}大概是这样吧
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货