[JAVA] A note about th: field th: each th: object of thymeleaf

with thymeleaf-spring4-2.1.5.RELEASE

<select th:field="*{income}">
  <option th:each="item : ${income_list}" th:object="${item}" th:value="*{code}">
    <span th:text="*{name}"></span>
  </option>
</select>

But

ERROR 44072 --- [nio-8091-exec-1] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8091-exec-1] Exception processing template "hoge/index": Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringOptionFieldAttrProcessor' (hoge/index)
ERROR 44072 --- [nio-8091-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Error during execution of processor 'org.thymeleaf.spring4.processor.attr.SpringOptionFieldAttrProcessor' (hoge/index)] with root cause

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'item' available as request attribute

Will result in the error. From before?

<select th:field="*{income}">
  <option th:each="item : ${income_list}" th:value="${item.code}">
    <span th:text="${item.name}"></span>
  </option>
</select>

It worked when he was cured.

By the way, it works when you remove th: field = "* {income}" of select.

With a memo.

Recommended Posts

A note about th: field th: each th: object of thymeleaf
Thymeleaf: Output with a delimiter when outputting with th: each
A note about Java GC
A note about the scope
A private note about AtomicReference
A note about the seed function of Ruby on Rails
A note about RocksDB's Column Families
[Ruby] Review about nesting of each
Explanation about Array object of Ruby
Make a note of Ruby keyword arguments
[Swift] A note about function and closure
A note about adding Junit 4 to Android Studio
A note about the Rails and Vue process