【发布时间】:2016-03-23 10:35:30
【问题描述】:
我在以下代码中使用fields.hasErrors,但出现错误:
评估 SpringEL 表达式的异常: "#fields.hasErrors('${parametrosFormulario[0].valor}')}" "
我有一个th:object="${parametrosFormulario}",我在以下行中使用它:
<div class="labelselect flota_izquierda col60"
th:each="parametro , stat: ${parametrosFormulario}"
th:classappend="${#fields.hasErrors('${parametrosFormulario[__${stat.index}__].valor}')}? 'labelselect_error'" >
我不知道我哪里错了。将不胜感激!
【问题讨论】:
-
我认为你在选择器 ${parametrosFormulario[${stat.index}].valor} thymeleaf 使用 pojo 对象和 getter setter 方法 ${#fields.hasErrors ('对象名')}
-
${parametrosFormulario} 是一个带有“valor”字段的对象列表。因此,通过执行“${parametrosFormulario[${stat.index}].valor}”,例如我在第一次迭代中传递了 ${parametrosFormulario[0].valor},我认为这是正确的。我不知道为什么它仍然给出错误。即使我执行 'parametrosFormulario[${stat.index}].valor' 它仍然不起作用
-
显示您的控制器代码以加深理解