0

I got strange error, which cannot access thymeleaf variable on child element, top one works but second one gets error.

I think second child gets error because of th:each, How can I fix this? Here's error line. Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method getAdminList() on null context object

<li
  class="setting"
  th:each="category : ${categories}"
  th:id="|category${category.getId()}|"    <- works
>
  <div class="setting_top">
    <div class="setting_img_frame">
      <img th:src="@{/images/{img}(img = ${category.getImg()})}" alt="" />    <- works
    </div>
    <div class="setting_right">
      <div class="setting_right_top"></div>
      <div class="setting_right_bottom" th:text="${category.getAbout()}"></div>    <- also works..
    </div>
  </div>

  <div class="setting_bottom">
    <li
      class="setting_tag"
      th:each="admin : ${category.getAdminList()}"    <- Error here, category does not exist
      th:text="${admin}"
      th:title="${admin}"
    ></li>
  </div>

</li>
gmma
  • 19
  • 1
  • 4
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 27 '22 at 10:17
  • It's not valid HTML to have a `
  • ` nested inside another `
  • ` like that. Instead, wrap your inner `
  • ...
  • ` inside a `
    • ...
    `. Do the same with the outer `
  • `, as well, for correctness.
  • – andrewJames Oct 27 '22 at 14:37
  • Does this answer your question? [Proper way to make HTML nested list?](https://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list) – andrewJames Oct 27 '22 at 14:37