JSP编写的网购系统action.java代码如下,购物车是通过什么方法怎么实现的?
cartAction.jsp//购物车添加商品publicStringadd(){HttpServletRequestrequest=ServletActionConte...
cartAction.jsp
//购物车添加商品
public String add() {
HttpServletRequest request = ServletActionContext.getRequest();
String productid = request.getParameter("productid");
Product product = this.productManager.queryById(Integer.parseInt(productid));
Cart entity = new Cart();
try {
entity.setUuid(SessionManager.getFrontUsername());
entity.setCounts(this.counts);
entity.setPrice(product.getPrice());
entity.setFileid(product.getFileid());
entity.setProductid(productid);
entity.setTotal(this.total);
entity.setName(product.getName());
this.cartManager.add(entity);
String returnMsg = BTAGI18N.getI18NValue("add.success", "common");
ActionContext.getContext().put(Const.Notification.SUCCESS, returnMsg);
return "successClose";
} catch(Exception e) {
ActionContext.getContext().put(Const.Notification.ERROR, e.getMessage());
return Const.Pages.MAPPING_URL;
}
} 展开
//购物车添加商品
public String add() {
HttpServletRequest request = ServletActionContext.getRequest();
String productid = request.getParameter("productid");
Product product = this.productManager.queryById(Integer.parseInt(productid));
Cart entity = new Cart();
try {
entity.setUuid(SessionManager.getFrontUsername());
entity.setCounts(this.counts);
entity.setPrice(product.getPrice());
entity.setFileid(product.getFileid());
entity.setProductid(productid);
entity.setTotal(this.total);
entity.setName(product.getName());
this.cartManager.add(entity);
String returnMsg = BTAGI18N.getI18NValue("add.success", "common");
ActionContext.getContext().put(Const.Notification.SUCCESS, returnMsg);
return "successClose";
} catch(Exception e) {
ActionContext.getContext().put(Const.Notification.ERROR, e.getMessage());
return Const.Pages.MAPPING_URL;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询