java - ThymLeaf:使用 th:{attribute} 设置现有属性
问题描述
在“为特定属性设置值”的ThymeLeaf 教程href
中,他们都定义了属性并使用th:href
.
取自文本的示例片段
<li><a href="product/list.html" th:href="@{/product/list}">Product List</a></li>
是否有理由包含href
标签,因为它无论如何都会被设置?如果有人想要页面的静态视图(即没有渲染器),他们是否设置了这些值?
解决方案
如果您的问题是如何使用 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";
}
推荐阅读
- javascript - 如何在云函数中查找循环 JSON 引用
- c++ - 从 .wsdl 创建 .h 时出现 gSoap 错误
- c# - 为什么 SerialPort 的 ReadByte 方法返回的是 Int 而不是 Byte?
- c++ - 结构包含在两个头文件中,我都不拥有
- ruby-on-rails - Rails:如何限制用户可以在回形针中上传的文件数量
- c - Complexity of a code in c programming language
- json - AsyncStorage 将 Promice 转换为 JSON 格式
- r - R中有没有办法计算如果有0,后续数字也将是零发生了多少次?
- postgresql - psql脚本执行不返回错误
- android - 本机插件android在离子上使用