我需要迭代,并创建<span>
针对每个元件component
中components
,其具有阵列name
的'MATERIAL'
我的代码如下
<span th:each="component : ${body.components}"
th:object="${component}">
<button th:if="*{name} == 'MATERIAL'"
th:text="*{title}"></button>
</span>
Run Code Online (Sandbox Code Playgroud)
这段代码一切正常,直到它产生一组空<span>
元素,如果name
它不相等'MATERIAL'
.我不希望这个空<span>
元素被创建.
我也试过以下
<span th:each="component : ${body.components}"
th:object="${component}"
th:if="*{name} == 'MATERIAL'">
<button th:text="*{title}"></button>
</span>
Run Code Online (Sandbox Code Playgroud)
这导致空输出并且根本不打印任何内容.有人可以帮我这个.