Let's say I have a Spring Controller like this:
@Controller
public class FooController {
@RequestMapping(value = "/foo", method = RequestMethod.GET)
public String update (Model model,
@RequestParam (value="id") String id,
@RequestParam (value="description") String description) {
Foo foo = new Foo(id, description);
fooService.create(update);
return "foo";
}
I'd like to re-write it like follows, but define my own request param mapping rather than let Spring's @ModelAttribute define it:
@Controller
public class FooController {
@RequestMapping(value = "/foo", method = RequestMethod.GET)
public String update(Model model,
@ModelAttribute("foo") Foo foo) {
fooService.update(foo);
return "foo";
}
Does anyone know how I would do this? I have looked at converters, PropertyEditors and using @RequestBody but I don't think any of these are quite right. I need to somehow override Spring's databinding it seems.
POSTrequests don't have query parameters. What exactly are you trying to do?@ModelAttributeSpring maps parameters to a model object automatically. What do you need to do?