【发布时间】:2015-06-17 18:20:02
【问题描述】:
我需要为components 数组中的每个component 迭代和创建<span> 元素,该数组具有name 的'MATERIAL'
我的代码如下
<span th:each="component : ${body.components}"
th:object="${component}">
<button th:if="*{name} == 'MATERIAL'"
th:text="*{title}"></button>
</span>
如果name 不等于'MATERIAL',则此代码运行良好,直到产生一组空的<span> 元素。我不希望创建这个空的 <span> 元素。
我也尝试了以下
<span th:each="component : ${body.components}"
th:object="${component}"
th:if="*{name} == 'MATERIAL'">
<button th:text="*{title}"></button>
</span>
这会导致空输出并且根本不打印任何内容。有人可以帮我解决这个问题吗?
【问题讨论】:
标签: java spring spring-mvc spring-boot thymeleaf