4

How can you use a command object with a GET request in an annotated controller under Spring 3?

I'd like to not having a bunch of @RequestParams in my method's arguments, and I have about 18 inputs that I need - so I wanted to be able to use a command object for this request..

Is there any sample code that I could see? I've used Spring 2.5 - and it's easy there - but how do you do it under Spring 3's annotations?

1 Answer 1

3

It works exactly the same way as with POST request - with @ModelAttribute (actually you can even omit @ModelAttribute - argument of a handler method is considered a model attribute if other options are not applicable):

@RequestMapping(...)
public ModelAndView foo(@ModelAttribute CommandObject cmd) { ... }

See also:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.