공부/Java, JSP
[Thymeleaf] Url with pathvariable
doublemetal
2015. 8. 11. 11:05
thymeleaf 가이드 문서의
Standard URL Syntax
을 살펴보면...
아래 {id}와 같은 구문을 사용할 수 있다고 나와 있다.
<
a
th:href
=
"@{/order/{id}/details(id=3,action='show_all')}"
>
하지만. 실제로 사용해보면.. 안되는 문제가 있는데..
<a th:href="@{'/order/details/' + ${id} + '/' + ${action}}">
이런 명확한 방법이 있는데 왜 안쓰냐.. 대충 이런 이야기인 것 같고(말이 많아서 보다 말았음..)
sof에서 아래 2가지 발견
http://stackoverflow.com/questions/14938344/thymeleaf-construct-url-with-variable
http://stackoverflow.com/questions/22059314/thymeleaf-spring-mvc-how-do-you-nest-variables-expressions-in-a-link-expressio
1. __...__ expression preprocessing <form th:action="@{/mycontroller/__${type}__}">
2. |...| pipeline syntax (|
) <link th:href="@{|/resources/libs/css/${view_name}.css|}" rel="stylesheet" />
1번 방법으로 적용!