1 package org.springframework.samples.jpetstore.web.spring; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import javax.servlet.http.HttpServletResponse ; 5 6 import org.springframework.samples.jpetstore.domain.Cart; 7 import org.springframework.web.servlet.ModelAndView; 8 import org.springframework.web.servlet.mvc.Controller; 9 import org.springframework.web.util.WebUtils; 10 11 15 public class RemoveItemFromCartController implements Controller { 16 17 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { 18 Cart cart = (Cart) WebUtils.getOrCreateSessionAttribute(request.getSession(), "sessionCart", Cart.class); 19 cart.removeItemById(request.getParameter("workingItemId")); 20 return new ModelAndView("Cart", "cart", cart); 21 } 22 23 } 24 | Popular Tags |