모델1 게시판 - 글목록 구현
http://injava.tistory.com/10 방법과의 차이점(장단점)을 학습
boardList.jsp : boardDao의 selectBoardListCount()메서드와 selectBoardListPerPage()메서드 호출
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <%@ page import="java.sql.*" %> <%@ page import="java.util.*" %> <%@ page import="service.*" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>BOARD LIST</title> </head> <body> <h1>BOARD LIST</h1> <% int currentPage = 1; if(request.getParameter("currentPage") != null) { currentPage = Integer.parseInt(request.getParameter("currentPage")); } BoardDao boardDao = new BoardDao(); int totalRowCount = boardDao.selectTotalBoardCount(); int pagePerRow = 10; int beginRow = (currentPage-1)*pagePerRow; List<Board> list = boardDao.selectBoardListPerPage(beginRow, pagePerRow); %> <div>전체행의 수 : <%=totalRowCount%>/<%=list.size()%></div> <table border="1"> <thead> <tr> <th>boardTitle</th> <th>boardUser</th> <th>boardDate</th> </tr> </thead> <tbody> <% for(Board b : list) { %> <tr> <td><a href="<%=request.getContextPath()%>/board/boardView.jsp?boardNo=<%=b.getBoardNo()%>"><%=b.getBoardTitle()%></a></td> <td><%=b.getBoardUser()%></td> <td><%=b.getBoardDate()%></td> </tr> <% } %> </tbody> </table> <div> <a href="<%=request.getContextPath()%>/board/boardAddForm.jsp">게시글 입력</a> </div> <% int lastPage = totalRowCount/pagePerRow; if(totalRowCount%pagePerRow != 0) { lastPage++; } %> <div> <% if(currentPage>1) { %> <a href="<%=request.getContextPath()%>/board/boardList.jsp?currentPage=<%=currentPage-1%>">이전</a> <% } if(currentPage < lastPage) { %> <a href="<%=request.getContextPath()%>/board/boardList.jsp?currentPage=<%=currentPage+1%>">다음</a> <% } %> </div> </body> </html> | cs |
'P. 자바 미니 프로젝트 > 모델1 게시판' 카테고리의 다른 글
P.2.6 모델1 게시판 만들기6 - 글수정 (2) | 2016.11.30 |
---|---|
P.2.5 모델1 게시판 만들기5 - 글삭제 (0) | 2016.11.30 |
P.2.4 모델1 게시판 만들기4 - 글내용 (0) | 2016.11.30 |
P.2.2 모델1 게시판 만들기2 - 글입력 (1) | 2016.11.30 |
P.2.1 모델1 게시판 만들기1 - DAO클래스 (1) | 2016.11.30 |