본문 바로가기

프로그래밍/Thymeleaf

[Thymeleaf] 현재 URL에 따라 class 동적 추가

소스 )

th:classappend="${#httpServletRequest.requestURI == tMenuVO.LINK_URL} ? on"

 

 

실제사용소스 )

<ul class="nav-list" id="top_menu">
   <li th:each="tMenuVO, i : ${menuInfo.topMenuList}" class="nav-item">
      <a th:href="${tMenuVO.LINK_URL}" th:value="${tMenuVO.MENU_ID}" th:text="${tMenuVO.TITLE}" class="nav-link" th:classappend="${#httpServletRequest.requestURI == tMenuVO.LINK_URL} ? on"></a>
   </li>
</ul>

 

'프로그래밍 > Thymeleaf' 카테고리의 다른 글

[Thymeleaf] 레이아웃 잡기  (0) 2022.02.19
[Thymeleaf] 타임리프 조건문  (0) 2022.02.08
[Thymeleaf] Thymeleaf란?  (0) 2019.08.26