JAVA

Hagi 2009. 11. 2. 14:28

사용설명은 다음에 올리려고한다. 현재 프로젝트 관계로 바쁘므로...

 

jar

hagi-Paging-1.1.jar

소스

Paging.java

스프링에서 xml 설정

hagiPaging_setting_spring.txt

컨트롤러에서

public ModelAndView list(HttpServletRequest request,
   HttpServletResponse response) throws Exception {
  ModelAndView mnv = new ModelAndView();
  List<Board> boardList = null;
  Paging paging = new Paging();
  //1.
  //2.
  bind(request, paging);
  int nowPage = paging.getNowPage();
  String searchColumn = paging.getSearchColumn();
  String searchWord = paging.getSearchWord();
  //3.
  this.paging.setPagingSet(nowPage, searchColumn, searchWord);
  int totalCount = boardService.getTotalCount(this.paging);
  this.paging.setTotalCount(totalCount);
  this.paging.setBoardListSet(nowPage);
  boardList = boardService.getBoardList(this.paging);
  //4.
  mnv.addObject("boardList",boardList);
  mnv.addObject("paging",this.paging);
  mnv.setViewName("board/list");
  return mnv;
 }
뷰에서

 <body>
<center>
<h1>게시판 목록</h1>
<table border="1">
 <tr>
  <th>번호</th>
  <th>제목</th>
  <th>작성자</th>
  <th>조회수</th>
  <th>날짜</th>
 </tr>
 <c:forEach var="board" items="${boardList}">
 <tr>
  <td>${board.seq }</td>
  <td><a
   href="read.do?seq=${board.seq }&nowPage=${paging.nowPage}">${board.title}</a>
  </td>
  <td>${board.member.userId }</td>
  <td><fmt:formatNumber pattern="#,##0" value="${board.readCount}"/></td>
  <td><fmt:formatDate pattern="yyyy년 MM월dd일 hh시mm분" value="${board.registDate}"/></td>
 </tr>
 </c:forEach>
</table>
<form name="frmSearch" action="list.do" method="post">
<input type="hidden" name="nowPage" value="${paging.nowPage }" />
<table>
 <tr>
  <td colspan="2">
  <c:if test="${!empty sessionUserId}">
   <a href="redit.do">글작성</a>   
  </c:if>
  </td>
  <td>
  <c:if test="${paging.startPageInNowPage > 1}">
   <a href="list.do?nowPage=${paging.prev }&searchWord=${paging.searchWord}&searchColumn=${paging.searchColumn}">이전</a>
  </c:if>
  </td>
  <td>
  <c:forEach var="indexI" begin="${paging.startPageInNowPage}" end="${paging.endPageInNowPage}" step="1">
   <a href="list.do?nowPage=${indexI }&searchWord=${paging.searchWord}&searchColumn=${paging.searchColumn}">[${indexI }]</a>
  </c:forEach>
  </td>
  <td>
  <c:if test="${paging.endPageInNowPage < paging.totalPage}">
   <a href="list.do?nowPage=${paging.next}&searchWord=${paging.searchWord}&searchColumn=${paging.searchColumn}">다음</a>
  </c:if>
  </td>
 </tr>
 <tr>
  <td align="center" colspan="5">
   <select id="searchColumn" name="searchColumn">
    <option value="">검색어</option>
    <option value="title">제목</option>
    <option value="content">내용</option>
   </select>
   <input type="text" id="searchWord" name="searchWord" size="20" maxLength="20" value="${paging.searchWord}" />
   <input type="submit" value="search"/>
  </td>
 </tr>
</table>
</form>
</center>
</body>

 

 

 

 

sql문이 없습니다.... 있으시면 좀 알려주세요