Geo*_*ris 5 html spring spring-mvc thymeleaf spring-boot
有没有办法在th:href链接中引用模型属性?例如
<a th:text="${currentUser}" th:href="@{/user/{currentUser}}"></a>
Run Code Online (Sandbox Code Playgroud)
这里,currentUser是控制器中指定的模型变量.这可以很容易地访问,如th:text标签中所示.但是,th:href无法解决百里香的问题.如果有任何方式以这种方式引用模型属性,在th:href?作为参考,这是一个支持Thymeleaf的Spring MVC(bootstrap)应用程序.
Lea*_*edo 10
为了包含模型变量,th:href
你必须将它包含在${...}
指标中,你可以使用管道轻松连接:
<a th:text="${currentUser}" th:href="@{|/user/${currentUser}|}"></a>
Run Code Online (Sandbox Code Playgroud)
在URL语法官方文档在这里.
归档时间: |
|
查看次数: |
10631 次 |
最近记录: |