게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
jsp 페이징 문의 드려요~
게시물ID : programmer_13336짧은주소 복사하기
작성자 : 개발자1
추천 : 0
조회수 : 282회
댓글수 : 1개
등록시간 : 2015/09/16 23:58:27
옵션
  • 본인삭제금지
한 페이지마다 게시글이 50개씩 보이게 하고 싶은데요..
int ListCount = (Count / 50) + 1; <-- 이렇게 하면 안되는 걸까요? .. 네.. 안되네요 ㅠㅠ
어느부분을 손봐야할지 조언좀 부탁드려요~~

// 페이징
   String p = request.getParameter("page");
   int page = 1;
   if (p != null) {
    page = Integer.parseInt(p);
   }
   int startRow = 10 * (page - 1) + 1;
   int endRow = startRow + 9;

   Dao Dao = new Dao();
   List<Bean> page_list = Dao.adList(startRow, endRow);

   String count = Dao.Count();
   int Count = Integer.parseInt(count);
   int ListCount = (Count / 10) + 1;

   int previous = page - (page % 5) - 1;
   if (previous < 1) {
    previous = 1;
   }
   int next = previous + 6;
   if (next > ListCount)
    next = ListCount;

이해를 돕기 위한 Count() 소스코드

// 카운트(페이지 번호)
 public String Count() {
  Connection conn = null;
  PreparedStatement pstmt = null;
  ResultSet rs = null;
  String Count = null;
  try {
   String sql = "select count(*) from TABLE";
   conn = ds.getConnection();
   pstmt = conn.prepareStatement(sql);
   rs = pstmt.executeQuery();
   while (rs.next()) {
    Count = rs.getString(1);
   }
  } catch (Exception e) {
   e.printStackTrace();
  } finally {
   close(rs);
   close(conn);
   close(pstmt);
  }
  return Count;
 }
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호