gpt4 book ai didi

java - ThymeLeaf:使用 th:{attribute} 设置现有属性

转载 作者:行者123 更新时间:2023-12-02 10:58:02 24 4
gpt4 key购买 nike

ThymeLeaf Tutorial对于“设置特定属性的值”,它们都定义了 href 属性并使用 th:href 设置它。

取自文本的示例片段

<li><a href="product/list.html" th:href="@{/product/list}">Product List</a></li>

是否有理由包含 href 标记,因为它无论如何都会被设置?他们是否设置这些值以防有人想要页面的静态 View ,即没有渲染器?

最佳答案

如果您问题是如何使用 href 添加 attr :

<li>
<a href="product/list.html" th:href="@{product/list(attrName=${attrValue})}">
Product List
</a>
</li>

如果您问题是如何重定向到静态页面:

// *** link to another page ***
<a th:href="@{staticPage}"> static page</a>

// *** Spring boot Controller ***
@RequestMapping(value="/staticPage", method=RequestMethod.GET)
public String staticPage(Model model) {
return "staticPage";
}

关于java - ThymeLeaf:使用 th:{attribute} 设置现有属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51567101/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com