protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Shoppingcart cart = new Shoppingcart();
List<Shoppingcart> cartList = (List<Shoppingcart>)request.getAttribute("cartList");
Object obj = new Object();
cart.setMovie(request.getParameter("name"));
cart.setPrice(Double.parseDouble(request.getParameter("price")));
cart.setQuantity(Integer.parseInt(request.getParameter("qty")));
cart.setRating(request.getParameter("rate"));
cart.setYearcreate(request.getParameter("year"));
cartList.add(cart);
request.setAttribute("cartList", cartList);
// ShoppingcartDao.insertShoppingcart(cart);
// request.getRequestDispatcher("cartList.jsp").include(request, response);
}
当程序到达cartList.add(cart);
时,它返回此方法的第一行;当到达cartList.add(cart);
时,它将跳过request.setAttribute("cartList", cartList);
并停止。
如何修复程序以继续request.setAttribute("cartList", cartList);
?