The @Controller is now the recommended way to build a controller in Spring-MVC. It allows any pojo to act as a MultiActionController, but without the need to extend any class. In a @Controller class you can group all logical actions together. The classes with the @Controller are found automatically through classpath scanning.
The @Controller maximally relies on naming-conventions for your classes and methods to intercept URL-patterns (e.g. "Hotels.index()" is accessible through "/hotels/index"). Of course, this is customizable. All action methods have plain java types, but can also, if needed, ask for special parameters like Request, Response,... etc. @MVC detects those parameter types and injects them automatically.
If the action-methods return a String, then this is assumed to be the view-identifier. If it's a non-string, the returned object is then made available for the view. The modelobject is named by using generics: e.g. List<hotel> will be called 'hotelList' in the view.
Spring JS
- enhance or decorate existing elements
- render subfragments --> uses Apache Tiles for composition
- use dojo query() to decorate multiple elements on a page.
- lighter, more consise syntax: e.g. first state is start-state by default.
- Ajax enabled through: ViewScope
- extensive Expression Language use
- abstract flows that can be extended
- better JSF support
- (new) best practice: put flow with associated template (e.g. jsp), messages and resources and in same directory --> relies on simpler defaults
- Spring Security
Will add a site-definition language to mix non-webflow pages with webflows.
No comments:
Post a Comment