【发布时间】:2015-06-15 13:55:59
【问题描述】:
我遇到了一个非常奇怪的错误!在对列表进行迭代时,thymeleaf 将 index 识别为我的 bean 的属性,而不是索引值!
<div th:each="phoneStat : *{phones}">
<select th:field="*{phones[__${phoneStat.index}__].variety}">
<option></option>
</select>
<div class=" input-field col s4">
<input class="validate" th:field="*{phones[__${phoneStat.index}__].number}"
th:id="${'phonenumber-'+ phones[__${phoneStat.index}__]}" type="text"/>
<label th:for="${'phonenumber-'+ phones[__${phoneStat.index}__]}"> Mobile</label>
</div>
</div>
我在这里做错了什么?请帮忙!
2015-06-15 15:48:25.453 ERROR 7764 --- [nio-8080-exec-6] 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: Exception evaluating SpringEL expression: "phoneStat.index" (/custom:89)] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 10): Property or field 'index' cannot be found on object of type 'com.ubleam.corporate.server.model.Phone' - maybe not public?
【问题讨论】:
标签: java spring spring-boot spring-mvc thymeleaf