Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Jsp Pagination
- egov
- mybatis
- ORA-01745
- Oracle
- 양동점
- JavaScript
- Responsively app
- 배딩작업
- 나주
- 카페
- ORA-00909
- docker
- SVN사용방법
- css
- 루키초밥
- Eclipse
- 은혜침구
- 맛집
- 문방구과자
- ORA-01005
- 요리
- 정민이초밥
- 반응형앱
- 광주
- RefreshableSqlSessionFactoryBean
- 디카페인
- AbstractViewe
- ORA-01756
- Java
Archives
- Today
- Total
gnusraun
Egov Pagination 페이지 처리 본문
728x90
Egov + Java + Mybatis + Oracle
:: Egov 페이지 처리 내용
이름 | 내용 | 입력 여부 |
공식 |
currentPageNo | 현재 페이지 번호 | O | |
recordCountPerPage | 한 페이지당 게시되는 게시물 건 수 | O | |
pageSize | 페이지 리스트에 게시되는 페이지 건수 | O | |
totalRecordCount | 전체 게시물 건 수 | O | |
totalPageCount | 페이지 개수 | X | totalPageCount = ((totalRecordCount-1)/recordCountPerPage) + 1 |
firstPageNoOnPageList | 페이지 리스트의 첫 페이지 번호 | X | firstPageNoOnPageList = ((currentPageNo-1)/pageSize)*pageSize + 1 |
lastPageNoOnPageList | 페이지 리스트의 마지막 페이지 번호 | X | lastPageNoOnPageList = firstPageNoOnPageList+pageSize-1 if(lastPageNoOnPageList>totalRecordCount) { lastPageNoOnPageList=totalPageCount } |
firstRecordIndex | 페이징 SQL의 조건절에 사용되는 시작 rownum | X | firstRecordIndex = (currentPageNo - 1) * recordCountPerPage |
lastRecordIndex | 페이징 SQL의 조건절에 사용되는 마지막 rownum | X | lastRecordIndex = currentPageNo * recordCountPerPage |
:: EgovImgPaginationRenderer.java
package egovframework.example.cmmn.web;
import egovframework.rte.ptl.mvc.tags.ui.pagination.AbstractPaginationRenderer;
import javax.servlet.ServletContext;
import org.springframework.web.context.ServletContextAware;
public class EgovImgPaginationRenderer extends AbstractPaginationRenderer implements ServletContextAware{
private ServletContext servletContext;
public EgovImgPaginationRenderer() {
// no-op
}
/**
* PaginationRenderer
*
* @see 개발프레임웍크 실행환경 개발팀
*/
public void initVariables() {
firstPageLabel = "<a href=\"#\" onclick=\"{0}({1}); return false;\">" + "<image src='" + servletContext.getContextPath() + "/images/egovframework/cmmn/btn_page_pre10.gif' border=0/></a> ";
previousPageLabel = "<a href=\"#\" onclick=\"{0}({1}); return false;\">" + "<image src='" + servletContext.getContextPath() + "/images/egovframework/cmmn/btn_page_pre1.gif' border=0/></a> ";
currentPageLabel = "<strong>{0}</strong> ";
otherPageLabel = "<a href=\"#\" onclick=\"{0}({1}); return false;\">{2}</a> ";
nextPageLabel = "<a href=\"#\" onclick=\"{0}({1}); return false;\">" + "<image src='" + servletContext.getContextPath() + "/images/egovframework/cmmn/btn_page_next1.gif' border=0/></a> ";
lastPageLabel = "<a href=\"#\" onclick=\"{0}({1}); return false;\">" + "<image src='" + servletContext.getContextPath() + "/images/egovframework/cmmn/btn_page_next10.gif' border=0/></a> ";
}
@Override
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
initVariables();
}
}
:: dispatcher-servlet.xml
<!-- For Pagination Tag image -->
<bean id="imageRenderer" class="egovframework.example.cmmn.web.EgovImgPaginationRenderer"/>
<!-- For Pagination Tag text -->
<bean id="textRenderer" class="egovframework.rte.ptl.mvc.tags.ui.pagination.DefaultPaginationRenderer"/>
<bean id="paginationManager" class="egovframework.rte.ptl.mvc.tags.ui.pagination.DefaultPaginationManager">
<property name="rendererType">
<map>
<entry key="image" value-ref="imageRenderer"/>
<entry key="text" value-ref="textRenderer"/>
</map>
</property>
</bean>
<!-- /For Pagination Tag -->
:: WebLogController.java
@Controller
public class WebLogController {
@Resource(name = "WebLogService")
private WebLogService webLogService;
// 웹 로그 리스트
@RequestMapping(value = "/weblog.do")
public String weblog(@RequestParam Map<String, Object> commandMap, HttpServletRequest req, ModelMap model) throws Exception {
// 날짜 체크
if(Utils.isEmpty(commandMap.get("nowDate"))) {
Date nowTime = new Date();
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
commandMap.put("nowDate", sf.format(nowTime));
}
// PaginationInfo에 필수 정보를 넣어 준다.
PaginationInfo paginationInfo = new PaginationInfo();
// 현재 페이지 체크
if(Utils.isEmpty(commandMap.get("currentPageNo"))) {
paginationInfo.setCurrentPageNo(1); // deault 번호
} else {
paginationInfo.setCurrentPageNo(Integer.parseInt(String.valueOf(commandMap.get("currentPageNo")))) ; //현재 페이지 번호
}
paginationInfo.setRecordCountPerPage(10); // 한 페이지에 게시되는 게시물 건수
paginationInfo.setPageSize(5); // 페이징 리스트의 사이즈
int firstRecordIndex = paginationInfo.getFirstRecordIndex();
int recordCountPerPage = paginationInfo.getCurrentPageNo() * paginationInfo.getRecordCountPerPage();
commandMap.put("firstIndex", firstRecordIndex);
commandMap.put("recordCountPerPage", recordCountPerPage);
List<?> webLogList = webLogService.selectWebLogList(commandMap);
int webLogCount = webLogService.selectWebLogCount(commandMap);
paginationInfo.setTotalRecordCount(webLogCount); //전체 게시물 건 수
//페이징 관련 정보가 있는 PaginationInfo 객체를 모델에 반드시 넣어준다.
model.addAttribute("paginationInfo", paginationInfo);
model.addAttribute("commandMap", commandMap);
model.addAttribute("webLogList", webLogList);
return "weblog/weblog";
}
}
:: Mybatis
<!-- 웹로그 개수 -->
<select id="selectWebLogCount" resultType="Integer">
<![CDATA[
SELECT
count(*)
FROM
th_web_log
WHERE
substr(reg_dt, 1, 8) = #{nowDate}
]]>
</select>
<!-- 웹로그 리스트 -->
<select id="selectWebLogList" resultType="egovMap">
<![CDATA[
SELECT * FROM
(
SELECT
row_number() over (order by seq asc) as num,
row_number() over (order by seq desc) as paging_num, seq, user_id, ip,
reg_dt, user_url, user_referer, user_agent, etc
FROM
th_web_log
WHERE
substr(reg_dt, 1, 8) = #{nowDate}
ORDER BY
seq desc
) WHERE paging_num > #{firstIndex} and paging_num <= #{recordCountPerPage}
]]>
</select>
:: Jsp
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!-- /Javascript -->
<script type="text/javascript">
function linkPage(pageNo) {
$("#formWebLog [name='currentPageNo']").val(pageNo);
$("#formWebLog").submit();
}
</script>
<!-- /Jsp HTML -->
<c:choose>
<c:when test="${fn:length(webLogList) == 0 }">
조회결과가 없습니다.
<br/>
</c:when>
<c:otherwise>
<div style="width:1200px;">
<table class="table" style="width:100%;table-layout:fixed;word-break:break-all;">
<thead class="thead-dark">
<tr>
<th scope="col" style="width: 8%;">번호</th>
<th scope="col" style="width: 10%;">사용자</th>
<th scope="col" style="width: 15%;">IP</th>
<th scope="col" style="width: 21%;">주소</th>
<th scope="col" style="width: 21%;">이전주소</th>
<th scope="col" style="width: 5%;">정보1</th>
<th scope="col" style="width: 20%;">정보2</th>
<th scope="col" style="width: 18%;">발생일자</th>
</tr>
</thead>
<tbody>
<c:forEach var="item" items="${webLogList}">
<tr>
<td>${item.num}</td>
<td>${item.userId}</td>
<td>${item.ip}</td>
<td>${item.userUrl}</td>
<td>${item.userReferer}</td>
<td>${item.userAgent}</td>
<td>${item.etc}</td>
<td>${item.regDt}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</c:otherwise>
</c:choose>
<!-- /Jsp Pagination -->
<ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="linkPage" />
출처 - https://alisyabob.tistory.com/243
728x90
'Backend > Egov' 카테고리의 다른 글
Egov org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement (0) | 2023.05.16 |
---|---|
Egov RefreshableSqlSessionFactoryBean 서버 재시작 없이 XML 반영 (0) | 2023.05.14 |
Egov 오라클 연동 (0) | 2023.05.13 |
Egov Scheduler 설정 (0) | 2023.05.13 |
Egov @ResponseBody Ajax 설정 (404 Error 발생) (0) | 2023.05.13 |