in my example, the @DateTimeFormat
annotation @DateTimeFormat
ignored when nesting objects:
class Person { private Date birthdate;
And I have a class that inserts these objects.
class PersonGroup { private Person person1; private Person person2; // other fields @Valid public Person getPerson1(){ return person1; } // also tried without @Valid-Annotation public Person getPerson2(){ return person2; } // Other getters/setters }
I am adding an object of type PersonGroup
to my model in @Controler
-Method:
model.addAttribute("myGroup", filledPersonGroup);
In JSP, I use print nested variables:
<form:form modelAttribute="myGroup" action="..." > <form:input path="person1.birthdate" > <form:input path="person2.birthdate" > ... </form:form >
But, unfortunately, the date values ββin the input fields are not formatted correctly (but the date is indicated in principle.). It works when I directly add an instance of the Person
class to the model.
Can someone tell me how I can handle this? I want the date of my nested objects to be formatted correctly.
I am using Spring 4.1.1-RELEASE
source share