use*_*645 4 loops nested double-quotes thymeleaf
我试过寻找现有的答案,但我找不到它们.
我想从ArrayList中的对象访问ArrayList,所以:
基本上有两个类:词汇表和Word.词汇表包含一个包含Word对象的列表,Word类包含一个包含更多Word对象的列表(相关词)
<table>
<span th:each="word : ${glossary.words}">
<td>
<tr th:each="relatedWord: ${word.relatedWords}">
<p th:text="${relatedWord.getName()}"></p>
</tr>
<td>
</span>
</table>
Run Code Online (Sandbox Code Playgroud)
不幸的是,这对我不起作用..
我不确定,但我认为你不能像你那样访问公共的非静态getter(假设getName()被标记为公共).
你应该试试:
<table>
<span th:each="word : ${glossary.words}">
<td>
<tr th:each="relatedWord: ${word.relatedWords}">
<p th:text="${relatedWord.name}"></p>
</tr>
<td>
</span>
</table>
Run Code Online (Sandbox Code Playgroud)
需要注意的是:上面的代码绝对不是有效的XHTML(span直接在里面table,tr直接在里面td).
| 归档时间: |
|
| 查看次数: |
10843 次 |
| 最近记录: |