The @ModelAttribute annotation can be used in two ways.
- First, it can be used as a parameter to a method to pass the entire model Object from the view to a handler method.
- Secondly, it can be used on a method to hold data for the view. It works great for populating lists for drop-downs to be displayed in the view.
As mentioned earlier, the @RequestMapping annotation is how Spring (really the DispatcherPortlet) determines what method to call on a given request. The request parameter is just a name/value pair. If your portlet is called without any request parameters the default method is the one that is invoked.
A couple others items to note; a render request handler can take RenderRequest and RenderResponse parameters and an action request handler can take ActionRequest and ActionResponse parameters. Often times an action request handler will have a void return type and set a render parameter on the response object to route the response to the correct render request handler (as seen in the activateUser() method below). The activateUser() method has a RequestMapping params of 'do=activateUser' and it also expects an 'id' as a request parameter.
You can see from just these three method signatures the flexibility you are given when using annotation based controllers. Again see the Portal MVC Documentation link below for details regarding what is allowed.