gpt4 book ai didi

java - 无法使用 Thymeleaf/Spring-Boot 迭代 List>

转载 作者:行者123 更新时间:2023-12-01 21:14:57 27 4
gpt4 key购买 nike

使用 Thymeleaf,我无法迭代 List >

 <tr th:each="row : ${rows}">
<td th:text="${row[0]}"></td>
<td th:text="${row[1]}"></td>
</tr>

每行都有超过 1 个值。

渲染时,出现以下异常

2016-11-02 20:40:21.033 ERROR 44829 --- [nio-5252-exec-1] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-5252-exec-1] Exception processing template "completed": Exception evaluating SpringEL expression: "row[1]" (completed:217)
2016-11-02 20:40:21.034 ERROR 44829 --- [nio-5252-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/test-dashboard] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "row[1]" (completed:217)] with root cause

org.springframework.expression.spel.SpelEvaluationException: EL1025E:(pos 3): The collection has '1' elements, index '1' is invalid

提前致谢。

最佳答案

双循环怎么样?

(注意,我不确定此 XHTML 的有效性,您可能必须使用与 HTML 下的 SPAN 不同的 TR 元素)

<tr th:each="row : ${rows}">
<span th:each="s : ${row}">
<td th:text="${s}"></td>
</span>
</tr>

关于java - 无法使用 Thymeleaf/Spring-Boot 迭代 List<List<String>>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40383460/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com