且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring MVC:如何在 Thymeleaf 中获取当前 url

更新时间:2022-01-31 00:21:29

哦,我找到了解决方案.我错过了文档中的 {#httpServletRequest.requestURI}.

Oh I got the solution for this. I missed the {#httpServletRequest.requestURI} in the documentation.

这是对我有用的解决方案:

Here is the solution which is working for me:

<a th:href="@{__${#httpServletRequest.requestURI}__/store/__${store.name}__}">Click to More</a>
//Will produce: http://localhost:8080/project/web/category/mobiles/store/samsung