Search code examples
spring-bootthymeleafmodelattribute

Exception evaluating SpringEL expression: "date_a" on code that works on 3 other pages


I have problem with this code...

<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>

I really dont get why this is not working... Its copy paste from other pages, which there are 3 of, and all the others are okey with this same snippet. But here i get error.

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

i pass an empty object on previous page with

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

EDIT:

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;
}

}


Solution

  • I still dont know if this about reserved keyword or something like that... changed form object name from Date to ThymeDate and now it works?

    if anyone have better explanation i can accept that as answer...