回答編集履歴

3

edit

2021/09/17 10:42

投稿

m.ts10806
m.ts10806

スコア80852

test CHANGED
@@ -62,4 +62,4 @@
62
62
 
63
63
 
64
64
 
65
- いずれにしても、何回もループさせるのはパフォーマンス的に良くないと思います。
65
+ いずれにしても、あっちもこっちも何回もループさせるのはパフォーマンス的に良くないと思います。

2

edit

2021/09/17 10:42

投稿

m.ts10806
m.ts10806

スコア80852

test CHANGED
@@ -21,3 +21,45 @@
21
21
  </table>
22
22
 
23
23
  ```
24
+
25
+
26
+
27
+ ```Thymeleaf
28
+
29
+ <table>
30
+
31
+ <tr>
32
+
33
+ <th>九九表</th>
34
+
35
+ <th th:each="i : ${#numbers.sequence(1, 9)}" th:value="${i}" th:text="${i}"></th>
36
+
37
+ </tr>
38
+
39
+ <th:block th:each="left : ${#numbers.sequence(1, 9)}" th:value="${left}">
40
+
41
+ <tr>
42
+
43
+ <td th:text="${left}"></td>
44
+
45
+ <th:block th:each="right : ${#numbers.sequence(1, 9)}" th:value="${right}">
46
+
47
+ <td th:text="${left * right}"></td>
48
+
49
+ </th:block>
50
+
51
+ </tr>
52
+
53
+ </th:block>
54
+
55
+ </table>
56
+
57
+ ```
58
+
59
+
60
+
61
+ あとはJava側で同じようにHTMLをStringに作ってutextで出力すれば「HTML側で計算」にはなってないかなと。
62
+
63
+
64
+
65
+ いずれにしても、何回もループさせるのはパフォーマンス的に良くないと思います。

1

edit

2021/09/17 10:40

投稿

m.ts10806
m.ts10806

スコア80852

test CHANGED
@@ -1,4 +1,4 @@
1
- 後程私も試してみますが、わざわざJava側で計算しなくても、numbers.sequence使えばThymeleaf側だけで出来そうに思います。
1
+ 後程私も試してみますが、わざわざJava側で計算しなくても、[numbers](https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#numbers).sequence使えばThymeleaf側だけで出来そうに思います。
2
2
 
3
3
 
4
4