异常评估 SpringEL 表达式:"date_a"适用于其他 3 个页面的代码



我对这段代码有问题。。。

<form action="#" th:action="@{'/portfolio/' + ${portfolios.getId()} + '/old' }" th:object="${Date}" method="post">
<table>
<tr>
<td>From: <input type="date" th:value="*{date_a}" th:field="*{date_a}" /></td>
</tr>
<tr>
<td><input type="submit" th:onclick="'javascript:loading()'" value="Change day" /></td>
</tr>
</table>

我真的不明白为什么这不起作用。。。它是从其他页面复制粘贴的,共有3个页面,所有其他页面都可以使用相同的片段。但我犯了错误。

org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "date_a" (template: "portfolio" - line 12, col 42)

我用在上一页传递一个空对象

ThymeDate date = new ThymeDate();
modelAndView.addObject("Date", date);

编辑:

ThymeDate

@Entity
@Table(name = "dto_thyme")
public class ThymeDate implements Serializable {
@Id
@GeneratedValue
long id;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate date_a;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate date_b;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public LocalDate getDate_a() {
return date_a;
}
public void setDate_a(LocalDate date_a) {
this.date_a = date_a;
}
public LocalDate getDate_b() {
return date_b;
}
public void setDate_b(LocalDate date_b) {
this.date_b = date_b;
}
public ThymeDate() {
}
public ThymeDate(LocalDate date_a, LocalDate date_b) {
this.date_a = date_a;
this.date_b = date_b;
}

}

我仍然不知道这是关于保留关键字还是类似的东西。。。将表单对象名称从Date更改为ThymeDate,现在可以工作了吗?

如果有人有更好的解释,我可以接受这个答案。。。

相关内容

最新更新