我用Spring Boot 2和百里香
以类名 SamplesTestResult
private Double compression;
private Double flexion;
我有一个 SamplesTestResult
列表<div th:each="testResult: ${samplesTestResult}" th:remove="tag">
<table>
<tr th:if="{testResult.compression!=null}">
<td th:text=" 'Compression ' + $ {}"></td><td th:text="'Requirement' + ${testResult.compression}"></td>
</tr>
<tr th:if="{testResult.flexion!=null}">
<td th:text=" 'Flexion ' + $ {}"></td><td th:text=" 'Requirement' + ${testResult.flexion}"></td>
</tr>
</table>
</div>
所以结果是
<table>
<tr>
<td>Compression 12</td>
<td>Flexion 14</td>
</tr>
</table>
<table>
<tr>
<td>Compression 22</td>
<td>Flexion 17</td>
</tr>
</table>
我搜索以获得
<table>
<tr>
<td>Compression 12, 22</td>
<td>Flexion 14, 17</td>
</tr>
</table>
我认为要实现这一点,我需要创建一种股票价值变量吗?