-
| 
         스터디시간에 생긴 질문 까먹기 전에 올립니다 ~ 타임리프에서 switch문을 사용하는 예시로 <tr th:each="user, userStat : ${users}">     
    <td th:text="${userStat.count}">1</td>      
   <td th:text="${user.username}">username</td>     
    <td th:switch="${user.age}">
            <span th:case="10">10살</span>
            <span th:case="20">20살</span>
            <span th:case="*">기타</span>
        </td>
    </tr>이 코드가 있었는데,              <span th:case="*">기타</span>
            <span th:case="10">10살</span>
            <span th:case="20">20살</span> | 
  
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            seyxxn
          
      
      
        Jul 20, 2024 
      
    
    Replies: 1 comment 3 replies
-
| 
        
 실제로 코드 변경하여 돌려보니, 모두 기타가 출력되는 결과값이 나왔습니다 ! 
  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    3 replies
                  
                
            
      Answer selected by
        6om1n
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
실제로 코드 변경하여 돌려보니, 모두 기타가 출력되는 결과값이 나왔습니다 !
th:case="*"구문과 자바의default구문이 유사한데,th:case="*"를 가장 위에 위치하게 하면 항상 이 블록이 매칭되어서 이 후의 다른 case 문은 절대로 실행되지 않는다고 합니다 !