Пример #1
0
  @RequestMapping
  public String list(
      int pageNo, int pageSize, String word, String order, HttpServletRequest request)
      throws Exception {

    int startIndex = 0;
    if (pageSize == 0) {
      pageSize = 3;
    }

    if (pageNo == 0) {
      pageNo = 1;
    }
    startIndex = (pageNo - 1) * pageSize;

    // JSP가 화면을 준비할 때 사용할 값을 ServletRequest에 담는다.
    List<BoardVo> list = boardDao.selectList(startIndex, pageSize, word, order);
    request.setAttribute("list", list);
    request.setAttribute("pageNo", pageNo);
    request.setAttribute("pageSize", pageSize);

    // 총 페이지 수 구하기
    int countAll = boardDao.countAll(word);
    int maxPage = countAll / pageSize;
    if (countAll % pageSize > 0) {
      maxPage++;
    }
    request.setAttribute("maxPage", maxPage);

    return "/board/BoardList.jsp";
  }
Пример #2
0
  @Override
  public String execute(HttpServletRequest request) throws Exception {
    BoardVo board = new BoardVo();
    board.setNo(Integer.parseInt(request.getParameter("no")));
    board.setTitle(request.getParameter("title"));
    board.setContent(request.getParameter("content"));

    boardDao.update(board);

    return "redirect:list.do";
  }