controller
@RequestMapping(value="/myCartList.do", method = RequestMethod.GET)
public ModelAndView myCartMain(HttpServletRequest request, HttpServletResponse response) throws Exception {
String viewName = (String) request.getAttribute("viewName");
ModelAndView mav = new ModelAndView(viewName);
HttpSession session = request.getSession();
MemberVO memberVO = (MemberVO) session.getAttribute("memberInfo");
String member_id = memberVO.getMember_id();
cartVO.setMember_id(member_id);
Map<String, List> cartMap = cartService.myCartList(cartVO);
session.setAttribute("cartMap", cartMap);
mav.addObject("cartMap", cartMap);
return mav;
}
service
public Map<String, List> myCartList(CartVO cartVO) throws Exception {
Map<String, List> cartMap = new HashMap<String, List>();
List<CartVO> myCartList = cartDAO.selectCartList(cartVO);
if (myCartList.size() == 0) {
return null;
}
List<GoodsVO> myGoodsList = cartDAO.selectGoodsList(myCartList);
cartMap.put("myCartList", myCartList);
cartMap.put("myGoodsList", myGoodsList);
return cartMap;
}