我该怎么做(java):
for(int i = 0; i < 81 ; i+=20){
//Should loop through 5 times!
}
Run Code Online (Sandbox Code Playgroud)
在Thymeleaf?
我试过这个:
<option th:each="i : ${#numbers.sequence( 1, 81/20)}">
<p th:text="${ i }"></p> <!-- THIS loops 4 times, instead of 5 -->
</option>
Run Code Online (Sandbox Code Playgroud)
问题是它不像java代码那么准确.这该怎么做?
我试过寻找现有的答案,但我找不到它们.
我想从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)
不幸的是,这对我不起作用..