fix(sample): 목록 행 번호가 페이지당 건수 대신 페이지 링크 묶음 크기를 쓰던 문제 수정 - #75
Merged
jei007 merged 1 commit intoSep 9, 2026
Merged
Conversation
EgovSampleController 는 두 값을 다른 축으로 나눠 넣는다. 86행은
pageUnit 을 PaginationInfo.recordCountPerPage(페이지당 건수)로,
87행은 pageSize 를 PaginationInfo.pageSize 로 넣는다. PaginationInfo
에서 pageSize 는 getFirstPageNoOnPageList/getLastPageNoOnPageList
에서만 쓰이는 페이지 링크 묶음 크기이고, 레코드 오프셋은
recordCountPerPage 로 계산한다. EgovSample_Sample_SQL.xml 73행의
LIMIT #{recordCountPerPage} OFFSET #{firstIndex} 도 같은 축이다.
그런데 egovSampleList.html 98행의 행 번호 식만 페이지당 건수 자리에
sampleVO.pageSize 를 곱하고 있었다. EgovConfigProperties 가 두 값을
모두 10 으로 두고 있어 기본 설정에서는 결과가 우연히 같지만, 값을
다르게 잡으면 2페이지부터 번호가 어긋난다. pageUnit=10, pageSize=5,
총 114건이면 2페이지 첫 행이 104 가 아니라 109 로 찍혀 1페이지 6번째
행과 번호가 겹친다.
컨트롤러 91행이 sampleVO.recordCountPerPage 를 이미 채워 두므로
템플릿에서 그 값을 쓰도록 바꿨다. 두 값을 다르게 설정하고 2페이지 첫
행 번호를 확인하는 테스트를 추가했다.
jei007
approved these changes
Sep 9, 2026
jei007
left a comment
Contributor
There was a problem hiding this comment.
표준프레임워크에 대한 지속적인 참여에
대단히 감사드립니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
수정 사유 Reason for modification
소스를 수정한 사유가 무엇인지 체크해 주세요. Please check the reason you modified the source. ([X] X는 대문자여야 합니다.)
수정된 소스 내용 Modified source
검토자를 위해 수정된 소스 내용을 설명해 주세요. Please describe the modified source for reviewers.
변경 사유
이 저장소는 페이지당 건수와 페이지 링크 묶음 크기를 서로 다른 축으로 나눠 씁니다.
EgovSampleController86행이pageUnit을PaginationInfo.recordCountPerPage로, 87행이pageSize를PaginationInfo.pageSize로 넣습니다.PaginationInfo에서pageSize는getFirstPageNoOnPageList·getLastPageNoOnPageList만 쓰는 링크 묶음 크기이고, 레코드 오프셋은getFirstRecordIndex가(currentPageNo - 1) * recordCountPerPage로 계산합니다.EgovSample_Sample_SQL.xml73행의LIMIT #{recordCountPerPage} OFFSET #{firstIndex}도 같은 축이고,EgovKrdsPaginationRendererTest106·107행이setRecordCountPerPage(10)과setPageSize(5)를 나란히 두는 것도 두 값이 다른 축이라는 전제입니다.egovSampleList.html98행의 행 번호 식만 페이지당 건수 자리에sampleVO.pageSize를 곱하고 있어 이 규약에서 혼자 벗어나 있습니다.변경 내용
컨트롤러 91행이
sampleVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage())로 값을 이미 채워 두므로 템플릿에서 그 값을 쓰도록 했습니다. 컨트롤러·SQL·설정은 그대로입니다.영향 범위
목록 템플릿은
egovSampleList.html하나이고 98행은th:each안의 No 칸이라 모든 목록 렌더가 이 식을 탑니다. 다만EgovConfigProperties16·17행이pageUnit과pageSize를 모두 10 으로 두고 있어 기본 설정에서는 두 식의 값이 같습니다 — 화면 출력은 바뀌지 않습니다.두 값을 다르게 잡으면 2페이지부터 어긋납니다.
pageUnit=10,pageSize=5, 총 114건이면 2페이지 첫 행이 104 가 아니라 109 로 찍혀 1페이지 6번째 행과 번호가 겹칩니다.sampleVO가@ModelAttribute라 URL 로pageSize를 넘겨도 컨트롤러 81행이 프로퍼티 값으로 덮어쓰므로 요청 파라미터만으로는 재현되지 않습니다.검증
추가한
EgovSampleControllerTestSelectListRowNumberTest는 중첩@TestConfiguration으로propertiesService빈을pageUnit=10·pageSize=5로 덮어쓰고(테스트application.properties에spring.main.allow-bean-definition-overriding=true가 이미 있습니다),/egovSampleList.do?pageIndex=2의 렌더 결과에서 첫 No 칸을 뽑아 모델의paginationInfo로 계산한 기대값과 비교합니다. 총건수를 하드코딩하지 않고 모델에서 파생시켜 다른 테스트의 INSERT 로 건수가 바뀌어도 깨지지 않습니다.수정 전 상태를 보려면 템플릿 98행을 되돌린 뒤 같은 명령을 돌립니다.
수정을 적용하고 같은 명령을 돌린 결과입니다.
전체 스위트(
mvn -B test)는 템플릿 98행만 토글해 두 번 돌렸습니다.Tests run: 55, Failures: 1, Errors: 0, Skipped: 0— BUILD FAILURETests run: 55, Failures: 0, Errors: 0, Skipped: 0— BUILD SUCCESS실패는 추가한 테스트 하나뿐이고, 기존 54건은 양쪽 모두 통과합니다.
JUnit 테스트 JUnit tests
테스트를 완료하셨으면 다음 항목에 [대문자X]로 표시해 주세요. When you're done testing, check the following items.
테스트 브라우저 Test Browser
테스트를 진행한 브라우저를 선택해 주세요. Please select the browser(s) you ran the test on. (다중 선택 가능 you can select multiple) [X] X는 대문자여야 합니다.
해당 없음 (기본 설정에서는 화면 출력이 바뀌지 않습니다)
테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
테스트 전과 후의 스크린샷 또는 캡처 영상을 이곳에 첨부해 주세요. Please attach screenshots or video captures of your before and after tests here.
기본 설정(
pageUnit=pageSize= 10)에서는 두 식의 결과가 같아 스크린샷으로 구분되지 않습니다. 위 실행 출력으로 대신합니다.