fix(sample): 목록 화면이 현재 페이지 번호를 상세·수정 경로로 넘기지 않는 문제 수정 - #73
Merged
jei007 merged 2 commits intoSep 9, 2026
Conversation
egovSampleList.html 의 히든 필드가 th:value="1" 로 고정돼 있어 #listForm
을 제출하는 sampleSearch·sampleCreate·sampleDetail 세 함수가 언제나
pageIndex=1 을 보낸다. 2페이지에서 ID 링크를 눌러도 상세 화면은 1페이지를
기억하고, 수정·삭제 완료 리다이렉트도 1페이지로 돌아간다.
컨트롤러는 반대로 pageIndex 를 보존하도록 짜여 있다.
updateSampleView 는 조회 결과에 setPageIndex 로 요청값을 다시 심고,
updateSample·deleteSample 은 redirectAttributes 에 pageIndex 를 실어
보낸다. 형제 템플릿 egovSampleRegister.html 의 같은 히든 필드도
th:value="${sampleVO.pageIndex}" 다. 목록 폼만 값을 버리고 있었다.
히든 필드를 sampleVO.pageIndex 에 연결한다. 같은 파일 98행이 이미
sampleVO.pageIndex 를 현재 페이지로 보고 순번을 계산하므로 모델에는
값이 들어 있다. 검색은 결과가 바뀌어 1페이지부터 봐야 하므로
sampleSearch 에서 값을 1로 되돌리며, samplePagination 이 페이지 번호를
넣는 방식과 같다.
EgovSampleControllerTestSelectListTest 에 pageIndex=2 로 목록을 조회해
렌더된 히든 필드가 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
문제
egovSampleList.html의 페이지 번호 히든 필드가th:value="1"로 고정돼 있습니다.이 필드는
#listForm안에 있고, 이 폼을 제출하는 함수는sampleSearch·samplePagination·sampleCreate·sampleDetail넷입니다. 이 중 값을 덮어쓰는 것은samplePagination뿐이라, 나머지 셋은 사용자가 몇 페이지를 보고 있든pageIndex=1을 보냅니다. 2페이지에서 ID 를 눌러 상세로 들어가면 상세 화면은 1페이지를 기억하고, 수정·삭제 완료 후 리다이렉트도 1페이지로 돌아갑니다.받는 쪽은 반대로 페이지 번호를 지키도록 짜여 있습니다.
EgovSampleController.updateSampleView는 조회 결과에 요청값을 다시 심고(155행detail.setPageIndex(sampleVO.getPageIndex())),updateSample(182행)·deleteSample(201행)은redirectAttributes에pageIndex를 실어 목록으로 돌려보냅니다. 같은 목적의 형제 템플릿egovSampleRegister.html82행의 히든 필드도th:value="${sampleVO.pageIndex}"입니다. 목록 폼 하나가 값을 버리는 바람에 그 세 곳이 전부 1만 왕복시키고 있었습니다.같은 파일의 목록 순번 계산이 이미
sampleVO.pageIndex를 현재 페이지로 쓰고 있어, 모델에는 값이 들어 있습니다.변경
히든 필드를 모델 값에 연결했습니다.
검색은 결과 집합이 바뀌어 1페이지부터 봐야 하므로
sampleSearch에서만 값을 1로 되돌립니다.samplePagination이$('#pageIndex').val(pageIndex)로 페이지 번호를 넣는 방식과 같습니다.function sampleSearch() { if (notNullCheck($('#searchKeyword').val())) { + $('#pageIndex').val(1); $('#listForm').attr('method', 'get').attr('action', contextPath + '/egovSampleList.do').submit();영향 범위
목록에서 상세로 들어가는 경로, 그리고 수정·삭제 완료 후 목록으로 돌아오는 리다이렉트입니다. 2페이지에서 글을 고치면 이제 2페이지로 돌아옵니다. 페이징 이동과 검색은 지금과 같이 동작합니다.
검증
EgovSampleControllerTestSelectListTest에pageIndex=2로 목록을 조회해 렌더된 히든 필드가 2를 내보내는지 확인하는 테스트를 추가했습니다. 히든 필드 한 줄만 되돌려 가며 전체 스위트를 돌린 결과입니다.mvn testTests run: 54, Failures: 0, Errors: 0, Skipped: 0— BUILD SUCCESSTests run: 55, Failures: 1, Errors: 0, Skipped: 0— BUILD FAILURETests run: 55, Failures: 0, Errors: 0, Skipped: 0— BUILD SUCCESS수정을 되돌렸을 때 실패하는 것은 추가한 테스트 하나뿐입니다.
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는 대문자여야 합니다.
브라우저 대신 앱을 띄워
curl로 응답 HTML 과 리다이렉트 헤더를 확인했습니다.테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
폼이 보내는 값이 상세 화면과 수정 완료 리다이렉트까지 그대로 이어지는 것을, 값만 바꿔 확인했습니다.