Thymeleaf에서 링크에 동적 파라미터, 동적 경로 추가 하
- 동적 파라미터 추가하기
----------------------------------------------------------------
사용예 :
body>
<ul>
<li th:each="dto : ${list}">
<a th:href="@{/sample/exView/(sno=${dto.sno})}" > [[${dto}]]</a>
</li>
</ul>
</body>
----------------------------------------------------------------
----------------------------------------------------------------
결과 :
<body>
<ul>
<li>
<a href="/sample/exView/?sno=1" > SampleDTO(sno=1, first=First..1, last=Last..1, regTime=2021-01-15T09:47:01.799899500)</a>
</li>
:
:
</ul>
</body>
----------------------------------------------------------------
- 동적 경로 추가하기
----------------------------------------------------------------
사용예 :
body>
<ul>
<li th:each="dto : ${list}">
<a th:href="@{/sample/exView/{sno}(sno=${dto.sno})}" > [[${dto}]]</a>
</li>
</ul>
</body>
----------------------------------------------------------------
----------------------------------------------------------------
결과 :
<body>
<ul>
<li>
<a href="/sample/exView/1" > SampleDTO(sno=1, first=First..1, last=Last..1, regTime=2021-01-15T09:50:04.046861900)</a>
</li>
:
:
</ul>
</body>
----------------------------------------------------------------
결론 :
th:href="@{/sample/exView/와 (sno=${dto.sno})}" 사이에 {sno}가 있고 없고에 따라 경로 or 파라미터 결정됨