【问题标题】:Spring thymeleaf th:each fails with Field or property "" cannot be found on nullSpring thymeleaf th:each 失败,字段或属性“”在 null 上找不到
【发布时间】: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>

【问题讨论】:

    标签: spring thymeleaf


    【解决方案1】:

    您有一个拼写错误 licnese.licenseName 而不是 license.licenseName。这可能是您的错误的原因

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-09
      • 1970-01-01
      • 1970-01-01
      • 2016-04-11
      • 2018-02-06
      • 1970-01-01
      • 2018-03-31
      相关资源
      最近更新 更多