【发布时间】:2019-07-29 02:28:26
【问题描述】:
给定两个对象:
public class MVCmodel {
UUID uuid;
NestedObject nestedObject = new NestedObject ();
}
public class NestedObject {
@Size(min = 2, max = 99)
String name = "";
}
百里香模板
<tr>
<td>
<input required="true" type="text" th:name="name"
th:value="${mVCmodel.getNestedObject.getName()}"
>
<span th:if="${#fields.hasErrors('name')}"
th:errors="${mVCmodel.getNestedObject().getName()}"
>Name Error
</span>
</td>
</tr>
我收到此错误: 评估 SpringEL 表达式的异常:“fields.hasErrors('name')”
SpringEL 尝试评估 mVCmodel.name 并且必须失败,因为 MVCmodel 中没有字段名称。
如何评估字段 mVCmodel.nestedObject.name?
【问题讨论】:
-
存在格式错误的 td 标签。小心
-
thx 已修复:(td> ->
)
标签: spring-boot spring-mvc thymeleaf