spring-boot - 在 Thymeleaf 片段中传递数组作为参数
问题描述
是否可以将数组传递给这样的片段:
<div th:replace="fragments :: test_fragment( {'one', 'two', 'three'} )"></div>
并像这样在片段中迭代:
<div th:fragment="test_fragment(numberArray)">
<span th:each="number : ${numberArray}" th:text="${number}"></span>
</div>
作为奖励,多维数组也可以吗?
我在 Spring Boot 2.0 项目中使用 Thymeleaf。
解决方案
对的,这是可能的。下面的代码应该可以解决问题。唯一的区别是${}
在数组之外添加了 ,。
<div th:replace="fragments :: test_fragment(${ {'one', 'two', 'three'} })"></div>
推荐阅读
- c# - 如何使用 PrincipalContext 将用户添加到 Active Directory 中的组
- email - 将调查中的电子邮件发送到odoo12中的电子邮件列表时重新加载错误
- python - python webdriver_manager chrome 自定义配置文件
- javascript - 如何在 App Center 崩溃报告中查看未缩小的 React Native JS 调用?
- javascript - 将 vue.js 应用程序中的本地脚本注入不同的组件
- python - 烧瓶形式 current_user NoneType
- node.js - 我如何使用 react js 进行支付 paytm 我已经在 spring boot 中构建了 api
- java - 比较 Spring Mysql 中的 2 个值
- mysql - 如何将所有表中数据库中的所有“id”列设置为自动增量?
- visual-studio-code - vscode vim 扩展不写真字符?