Last updated by admin
5 years ago
Spring MVC Integration
Grails uses Spring MVC as the underlying web application framework. Spring MVC might not be the simplest framework to use but it is most definitely one of the most extensible making it perfect for Grails. The Grails servlet extends Spring's DispatcherServlet to bootstrap the Grails environment, there is then a single Spring MVC controller called org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController that handles all Grails controller requests.The SimpleGrailsController delegates to a class called org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper that actually handles the request. This class breaks the handling of the request down into a number of steps. The entry point for the class is the {{handleUri}} method which:- Parses the URI into its components (controller name, action name, id etc.)
- Looks up a GrailsControllerClass instance for the URI
- Creates a new Grails controller instance
- Configures the controller instance's dynamic methods and properties
- Retrieves a scaffolder if is scaffolding is enabled for the controller
- Gets a reference to the closure action to execute for the URI
- Increments flash scope moving it on to its next state
- Gets the view name for the URI
- Executes any before inteceptors registered
- Executes the closure that is the controller action if the before interceptor didn't return false
- Creates a Spring MVC ModelAndView instance from the view name and the model returned by the closure action
- Executes any after interceptors registered passing returned model
- Returns the Spring MVC ModelAndView instance