使用 Thymeleaf 以绝对 URL 映射变量
Mapping a Variable in an Absolute URL using Thymleaf
我正在写一个 HTML 电子邮件模板,我正在尝试使用 thymleaf 在超链接中映射一个变量(用户名)。
所以我的 URL 看起来像这样:https://example.com/#/login?username=johndoe
我尝试了以下方法,但映射没有按预期工作
<p> <a th:href="@{https://example.com/#/login(username=${username})}">https://example.com/#/login?username=${username}</a></p>
我没想到映射的第二部分能正常工作。
我想要的输出是这样的:
<p> <a href="https://example.com/#/?/login?username=johndoe">https://example.com/#/?/login?username=johndoe</a></p>
如有任何帮助,我们将不胜感激。谢谢!
你能试试
<p> <a th:href="@{'https://example.com/#/login?username='+ ${username}}">https://example.com/#/login?username=${username}</a></p
我正在写一个 HTML 电子邮件模板,我正在尝试使用 thymleaf 在超链接中映射一个变量(用户名)。
所以我的 URL 看起来像这样:https://example.com/#/login?username=johndoe
我尝试了以下方法,但映射没有按预期工作
<p> <a th:href="@{https://example.com/#/login(username=${username})}">https://example.com/#/login?username=${username}</a></p>
我没想到映射的第二部分能正常工作。
我想要的输出是这样的:
<p> <a href="https://example.com/#/?/login?username=johndoe">https://example.com/#/?/login?username=johndoe</a></p>
如有任何帮助,我们将不胜感激。谢谢!
你能试试
<p> <a th:href="@{'https://example.com/#/login?username='+ ${username}}">https://example.com/#/login?username=${username}</a></p