rivate boolean add(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String id = req.getParameter("id"); int number = Integer.parseInt(req.getParameter("number")); Items item = idao.getItemsById(Integer.parseInt(id)); if (req.getSession().getAttribute("cart") == null) { Cart cart = new Cart(); req.getSession().setAttribute("cart", cart); cart.addGoodsInCart(item, number); } else { Cart cart = (Cart) req.getSession().getAttribute("cart"); cart.addGoodsInCart(item, number); } return true; }
你再看一下老师写的吧
没看出来错误,截个图看看