I thought that @RequestBody tries to map request params to the object after the annotation by the property names.
But if I got:
@RequestMapping(value = "/form", method = RequestMethod.GET)
public @ResponseBody Person formGet(@RequestBody Person p,ModelMap model) {
return p;
}
The request:
http://localhost:8080/proj/home/form?id=2&name=asd
Return 415
When I change @RequestBody Person p with @RequestParam Map<String, String> params it's OK:
@RequestMapping(value = "/form", method = RequestMethod.GET)
public @ResponseBody Person formGet(@RequestParam Map<String, String> params) {
return new Person();
}
Person class:
public class Person{
private long id;
private String name;
public Person() {
}
public Person(long id, String name) {
super();
this.id = id;
this.name = name;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Spring vresion 3.2.3.RELEASE
Where did I go wrong?