fix(sample): 컨텍스트 패스 하위 배포 시 폼 액션이 루트로 만들어지는 문제 수정 - #78
Merged
jei007 merged 1 commit intoSep 11, 2026
Merged
Conversation
common.js 는 #contextPathHolder 엘리먼트의 data-contextPath 를 읽어
contextPath 변수를 만들고, 목록·등록 화면의 폼 액션 8군데가 이 값을 앞에
붙인다. 그런데 그 엘리먼트를 렌더하는 템플릿이 없어 값이 늘 '' 이다.
v4.3.0 까지는 두 템플릿이 head 에 <link id="contextPathHolder"> 를 직접
넣었는데, v5.0.0 에서 읽는 쪽만 common.js 로 옮기면서 넣는 쪽이 빠졌다.
server.servlet.context-path=/sample 로 띄우면 CSS·JS 는 @{...} 덕에
/sample 이 붙지만 검색·페이징·등록·상세·수정·삭제·목록 버튼은
/egovSampleList.do 로 제출돼 404 가 난다.
같은 파일이 정적 자원에 이미 쓰고 있는 @{...} 로 액션 URL 을 만들어 DOM
왕복을 없앤다. 쓰는 곳이 없어진 common.js 의 contextPath 선언도 지운다.
컨텍스트 패스가 없는 기본 배포에서는 만들어지는 URL 이 종전과 같다.
wantaekchoi
force-pushed
the
fix/context-path-holder-missing
branch
from
September 10, 2026 02:37
ea78473 to
850ac43
Compare
jei007
approved these changes
Sep 11, 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
수정된 소스 내용 Modified source
common.js첫 줄이 컨텍스트 패스를 DOM 에서 읽습니다.#contextPathHolder는 저장소 전체에서 이 한 줄에만 나옵니다. 그 엘리먼트를 렌더하는 템플릿이 없어 선택자가 아무것도 잡지 못하고, 값은 늘''입니다.이 변수는
egovSampleList.html(16·24·29·34줄)과egovSampleRegister.html(31·40·51·58줄)의 폼 액션 여덟 군데에 그대로 앞에 붙습니다. 검색·페이징·등록화면·상세·목록·등록·수정·삭제 버튼이 만드는 URL 이 전부 루트 기준이 됩니다.같은 파일의
<head>는 CSS·JS 를 이미th:href="@{/css/egovframe.css}"처럼 걸고 있습니다. 한 파일 안에서 URL 을 만드는 방식이 둘로 갈리고, 그중 하나만 컨텍스트 패스를 놓칩니다.v5.0.0 직전 릴리스인 v4.3.0(
89724ea)까지는 두 템플릿이<head>에서 홀더를 직접 넣었습니다. 홀더를 지운 커밋은 v5.0.0 임포트(95b2f01) 하나뿐입니다.v5.0.0(
95b2f01)에서 읽는 쪽만common.js로 옮겨지고, 넣는 쪽이 함께 옮겨지지 않았습니다.홀더를 그대로 되살리지는 않았습니다.
${#httpServletRequest}는 Thymeleaf 3.1 에서 없어진 표현식이고(이 빌드가 받는 버전은org.thymeleaf:thymeleaf:jar:3.1.3.RELEASE), 두 파일에는 정적 자원이 이미 쓰는@{...}가 있습니다.변경
폼 액션도 정적 자원과 같은 방식으로 만듭니다.
나머지 일곱 군데도 같은 모양입니다. DOM 을 거치지 않게 되면서 참조가 없어진
common.js의contextPath선언은 함께 지웠습니다.영향 범위
목록·등록 두 화면의 폼 액션 여덟 군데입니다. 컨텍스트 패스가 없는 기본 배포에서는 만들어지는 URL 이 종전과 같습니다(아래 18081 은 컨텍스트 패스 없이 따로 띄운 인스턴스입니다).
common.js의 전역 선언 삭제는 공용 파일 변경입니다. 저장소 안 참조는 위 여덟 군데가 전부라 이번 변경으로 0 이 되지만, 이 샘플을 복사해 자기 화면을 만들면서 그 전역을 쓰고 있다면 그쪽도@{...}로 함께 바꿔야 합니다.JUnit 테스트 JUnit tests
가설은 "컨텍스트 패스
/sample로 두 화면을 렌더하면 화면에 나타난*.do경로가 모두/sample로 시작해야 한다" 입니다.EgovSampleControllerTestContextPathTest가 경로별로 등장 횟수와/sample이 붙은 등장 횟수를 대조합니다.수정 전
수정 후
테스트 브라우저 Test Browser
브라우저 대신
server.servlet.context-path=/sample로 실제 기동해 응답 본문을 확인했습니다.테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
수정 전 — 정적 자원에만
/sample이 붙고 폼 액션에는 붙지 않습니다.수정 후