I am using Thymeleaf Template Engine with Spring Web MVC and I am got stuck while creating url's with the help of current url. Is there any way to get current inside Thymeleaf HTML file? eg: Suppose my current url in my browser address bar is:
http://localhost:8080/project/web/category/mobiles
and now I want to make a url like this http://localhost:8080/project/web/category/mobiles/store/samsung
or
http://localhost:8080/project/web/category/mobiles?min_price=10&max_price=100
.
So I the code will look like this
<a th:with="currentUrl='http://localhost:8080/project/web/category/mobiles'"
th:href="@{__${currentUrl}__/__${store.name}__}">
Click to More Result
</a>
Here I am using currentUrl
variable with hardcoded url, So I want to some solution for the same. The hardcoded value will not work everytime because I have dynamic categories.
I tried the same with relative url but its not working for me.
<a th:href="@{/store/__${store.name}__}">Click to More</a>
//will produce: http://localhost:8080/project/web/store/samsung
//I want: http://localhost:8080/project/web/category/mobiles/store/samsung
Please have a look and let me know if am I doing something wrong.
http://localhost:8080/project
is my base url and/web/category/{categoryName}
is mapped by controller. I tried the relative but it doesn't seems to work, I am using this for relative urls<a th:href="@{/store/__${store.name}__}>" Click to More</a>
. – Hinton