@RequestMapping(value = "/list.do") public ModelAndView guestList(@RequestParam(value = "pagenum", defaultValue = "1") int pagenum) { int countall = dao.countAll(); // int countall =286; int pageSize = 10; int limit = 8; int pageAll = 1; if (countall % pageSize == 0) { pageAll = (countall / pageSize); } else { pageAll = (countall / pageSize) + 1; } // int start = ((pagenum-1)*limit)+1; //[2]..11~ // int end = (pagenum*limit); //[2]..~20 int tmp = (pagenum - 1) % limit; int startPage = pagenum - tmp; int endPage = startPage + pageSize - 1; ModelAndView mav = new ModelAndView(); System.out.println("\nModelAndView guestList()"); List<GuestDTO> bean = dao.dbSelect(startPage, endPage); System.out.println("startPage : endPage :::: " + startPage + "\t" + endPage); System.out.println("pageAll : " + pageAll); // System.out.println("bean : " + bean.toString()); mav.addObject("pagenum", pagenum); mav.addObject("startPage", startPage); mav.addObject("endPage", endPage); mav.addObject("pageAll", pageAll); mav.addObject("bean", bean); mav.addObject("countAll", countall); String url = "/WEB-INF/views/guestList.jsp"; mav.setViewName(url); return mav; } // end
@RequestMapping(value = "/list2.do", method = RequestMethod.GET, consumes = "application/json") public @ResponseBody List<GuestDTO> guestList2( Model model, @RequestParam(value = "start", defaultValue = "1") int start, @RequestParam(value = "end", defaultValue = "10") int end, @RequestParam(value = "pagenum", defaultValue = "1") int pagenum) { System.out.println("list2 start end " + start + " :: " + end); int countall = dao.countAll(); // int countall =286; int pageSize = 10; int limit = 8; int pageAll = 1; if (countall % pageSize == 0) { pageAll = (countall / pageSize); } else { pageAll = (countall / pageSize) + 1; } // int start = ((pagenum-1)*limit)+1; //[2]..11~ // int end = (pagenum*limit); //[2]..~20 int tmp = (pagenum - 1) % limit; int startPage = pagenum - tmp; int endPage = startPage + pageSize - 1; ModelAndView mav = new ModelAndView(); System.out.println("\nModelAndView guestList()"); List<GuestDTO> list = dao.dbSelect(start, end); System.out.println("list2 : " + list.toString()); // model.addAttribute("countAll",countall); System.out.println("pageAll : " + pageAll); // System.out.println("bean : " + bean.toString()); return list; } // end