Posts

Showing posts from 2010

How does @ModelAttribute Work?

Image
@ModelAttribute is a Spring-MVC annotation that is used for preparing the model data. It is also used to define the command object for binding the HTTP request data. The annotation works only if the class is a Controller class (i.e. annotated with @Controller ). ModelAttribute can be applied to both methods as well as method-parameters. It accepts an optional "value" , which indicates the name of the attribute. If no value is supplied to the annotation, then the value would default to the return type name in case of methods and parameter type name in case of method-parameters. The way Spring processes this annotation is,

What Is a SessionAttributeStore? When to Use It?

Image
In one of my projects, I had an abstract controller class that simulated the form controller of Spring 1.2 for session forms. Annotations do not accept dynamic parameters. They have to be static. So, in the class, the command object name had to be a constant.

Spring MVC - mvc:annotation-driven - What does it do?

Image
The annotations based MVC was introduced to the framework in Spring 2.5. This model enables the developer to reuse any POJO as a controller and is very flexible with the handler signatures. The old controller hierarchy is deprecated as of Spring 3.0. It would be removed completely from the distribution in one of the future releases.