2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

thymeleaf の th:field th:each th:object のあたりのメモ

Posted at

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>

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

というエラーになる。前から?

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

と治したら動いた。

ちなみに、select の th:field="*{income}" を外すと動く。

メモで。

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?