⚙️ Backend/스프링(Spring) Framework
스프링 - 검색 페이징 처리
반응형
스프링 - 검색 페이징 처리
boardMapper.xml
<select id="getTotal" resultType="_int">
select count(*) from tbl_board where
<include refid="criteria"> </include>
<include refid="criteria"></include>
bno > 0
</select>
BoardService.java
서비스 수정
public int getTotal(Criteria cri);
BoardServiceImple.java
주입 수정
@Override
public int getTotal(Criteria cri) {
return mapper.getTotal(cri);
}
BoardMapper.java
에서 추가
public int getTotal(Criteria cri);
BoardController.java
컨트롤러 수정
@GetMapping("/list")
public void list(Criteria cri, Model model) {
log.info("list");
model.addAttribute("list", service.getList(cri));
model.addAttribute("pageMaker", new PageDTO(cri, service.getTotal(cri)));
}
list.jsp
뷰 페이지 수정
<select name="type">
<option value="" ${pageMaker.cri.type == null ? 'selected':''}>검색 기준</option>
<option value="T" ${pageMaker.cri.type == 'T' ? 'selected':''}>제목</option>
<option value="C" ${pageMaker.cri.type == 'C' ? 'selected':''}>내용</option>
<option value="W" ${pageMaker.cri.type == 'W' ? 'selected':''}>작성자</option>
<option value="TC" ${pageMaker.cri.type == 'TC' ? 'selected':''}>제목 또는 내용</option>
<option value="TW" ${pageMaker.cri.type == 'TW' ? 'selected':''}>제목 또는 작성자</option>
<option value="TCW" ${pageMaker.cri.type == 'TCW' ? 'selected':''}>전체</option>
</select>
<input id="keyword" type="text" name="keyword" value="${pageMaker.cri.keyword}">
<a href="javascript:void(0)" class="search button primary icon solid fa-search">검색</a>
<form id="actionForm" action="/board/list">
<input type="hidden" name="pageNum" value="${pageMaker.cri.pageNum}">
<input type="hidden" name="amount" value="${pageMaker.cri.amount}">
<input type="hidden" name="type" value="${pageMaker.cri.type}">
<input type="hidden" name="keyword" value="${pageMaker.cri.keyword}">
</form>
반응형
'⚙️ Backend > 스프링(Spring) Framework' 카테고리의 다른 글
스프링(Spring) - 컨트롤러 result 보낼 때 한글 깨짐 현상 (0) | 2021.05.24 |
---|---|
스프링 - Ajax 댓글 처리 구현 (0) | 2021.05.17 |
스프링 - 페이징 화면 처리에 관하여.. (0) | 2021.05.13 |
스프링 - 검색 처리 구현, 동적 쿼리에 관하여.. (0) | 2021.05.13 |
스프링 프로젝트에 템플릿 적용시키기 (0) | 2021.05.11 |
댓글