我正在使用Thymeleaf模板引擎和Spring Web MVC,我在当前网址的帮助下创建url时遇到困难.有没有办法在Thymeleaf HTML文件中获取最新信息?例如:假设我的浏览器地址栏中的当前网址为:
http://localhost:8080/project/web/category/mobiles
现在我想做一个像这样的网址 http://localhost:8080/project/web/category/mobiles/store/samsung
要么
http://localhost:8080/project/web/category/mobiles?min_price=10&max_price=100.
所以我的代码看起来像这样
<a th:with="currentUrl='http://localhost:8080/project/web/category/mobiles'"
th:href="@{__${currentUrl}__/__${store.name}__}">
Click to More Result
</a>
Run Code Online (Sandbox Code Playgroud)
这里我使用currentUrl变量与硬编码的URL,所以我想要一些解决方案相同.硬编码的值不会每次都有效,因为我有动态类别.
我尝试了相同的url,但它不适合我.
<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
Run Code Online (Sandbox Code Playgroud)
请看看,如果我做错了,请告诉我.