Skip to content
Discussion options

You must be logged in to vote

실제로 코드 변경하여 돌려보니, 모두 기타가 출력되는 결과값이 나왔습니다 !
th:case="*" 구문과 자바의 default 구문이 유사한데,
th:case="*"를 가장 위에 위치하게 하면 항상 이 블록이 매칭되어서 이 후의 다른 case 문은 절대로 실행되지 않는다고 합니다 !

정리
th:switch는 첫 번째 매칭되는 th:case 블록만 실행하고 나머지만 무시한다.
따라서 th:case="*"를 맨 위에 배치하면 모든 경우가 해당되기 때문에 다른 case 문을 실행하지 않게 된다.

Replies: 1 comment 3 replies

Comment options

seyxxn
Jul 20, 2024
Maintainer Author

You must be logged in to vote
3 replies
@im1sun
Comment options

@6om1n
Comment options

@YuDeokRin
Comment options

Answer selected by 6om1n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 participants