【发布时间】:2023-03-11 00:28:01
【问题描述】:
我是 Thymeleaf 的新手,但我还有其他一些页面在工作。但是,这是我第一次使用 th:each 并且出现错误。在运行时,我得到“在 null 上找不到字段或属性‘licenseName’”。我运行了调试,并且在我的 ModelAnView 对象中传递了一个对象的 ArrayList。我已经将模型键复制并粘贴到 th:each 属性中,以防我输入错误。这是有问题的代码:
<select th:remove="all-but-first" id="accountPlans">
<option th:each="license : ${availableLicenses}" th:text="${licnese.licenseName}" value="None">-- Select a Plan --</option>
<option value="Free">Free - A plan to learn the basics</option>
<option value="Intro">Intro - Starter plan for a small founding group</option>
<option value="Basic">Basic - A plan for a small group</option>
</select>
【问题讨论】: