I have the following Person
class containing another Car
class
public class Person {
private String name
private Car car;
... getter and setters
}
public class Car {
private String manufacturer;
... getter and setters
}
In Javascript I do the following:
person = new Object();
person.name = "Bob";
person.car = new Object();
car = person.car;
car.manufacturer = "Mercedes";
$.ajax({
url: 'someurl.com',
type: 'POST',
data: person,
dataType: 'json',
...
complete: function() {
...
}
});
When using the autobinding function I get the following error:
Function:
public @ResponseBody Car validateCar( Car car, HttpServletRequest servletRequest){
...
}
Error:
org.springframework.beans.InvalidPropertyException: Invalid property 'car[manufacturer]' of bean class [com.example.Person]: Property referenced in indexed property path 'car[manufacturer]' is neither an array nor a List nor a Map; returned value was []
What do I have to do to make the mapping work?
btw: my POST data looks like this:
name: Bob
car[manufacturer]: Mercedes
stringified as JSON it looks the following (i tested it but I don't stringify it)
{"name":"Bob",
"car": {
"manufacturer":"Mercedes"
}
}