$.ajax({
cache:false,
type: 'POST',
url: "${saveDTO}",
data: mySubmitData, //a stringified json object, a form converted using toObject plugin
contentType: "application/json",
success: function(data) {
savedDialog.html( JSON.stringify(data) + "<br><br>"+mySubmitData);
}
});
and the controller is :
public @ResponseBody MyDTO saveDTO(@Valid final MyDTO myDTO,BindingResult result, Model model){
System.out.println(myDTO.getMyField + " " + myDTO.getSecondField;
return new MyDTO();
}
The output I get in dialog shows this :
{"myField":null,"secondField":null} //new empty dto converted and returned spring
{"myField":"RU","secondField":"13-02-12"} //submitted data, a form converted to json
Whilst my sys out console output shows both fields are null, the json has not bound !!! Why ? The DTO itself just has two private fields with appropriate getters/setters
1 Answer