25. Spring MVC Introduction

Spring MVC
1.     MVC supports
·         Form Backup : data stored in Beans, then validate, we use spring-tag library
·         Controllers
a.       MultiAction --> save, update, find for all we can use single controller
b.      MultiForm --> Multiple  form data from diff pages we can handle single controller
·         Validation Support
·         I18N suport
·         Inrerceptors
·         view resolvers
·         Exception Handling
2.       Spring MVC Container
·         MVC Container name is WebApplicationContextContainer(IoC)
·         JSP model architecture is recommended to design Spring-MVC
·         we have some helping controllers in the case of MultiForm/ Multiaction

3.       Spring Front Controller
Frontcontroller --> used for common required operations []
                                                   i.      JSP MODEL -1 :  JSP  as a Front Controller
                                                 ii.      JPS MODE; -2 : Servlet as a Front Controller(Struts 1| Spring MVC| JSF)
                                                iii.      JSP MODEL-3 : Filters as Front controller(Struts 2)
                                               iv.      JSP MODEL-4 Tag Support  as Front controller
Examples of FrontControllers in different Frameworks
1.     Struts1          à ActionServlet
2.     Struts2          à FilterDispatcher / StructsPrepairandExecute
3.     JSF                  à FacesServlet      
4.     Spring           à DispatcherServlet
4.     In Spring.xml

·         If our jsp has Registration, getData, Login as url patterns , we configure that in a web.xml
·         name : [            ]  action="/hello.htm"
·         Configure Frontcontroller à DispatcherServlet in web.xml
·         for doing specific logic we have to configure controller
·         Controller(I) --> public  modelAndView handleRequest(req, res)                                returns modelAndView ("sucesss", map)
·          We write spring-servlet.xml file, we need to write map data. It’s like structs.xml
·         to solve success pages we have to use "InternalResorceViewResolver", had 2 methods prefix(location) and suffix(.extension) methods
5.       Controller’s in Spring MVC
Core controllers
1.       Controller
2.       Abstarct Controller
Form Controller
1.       ParametarizableViewController
2.       UrlFileNameViewController

1.       BeanNameUrlHandlerMapping (def.)
2.       ControllerClassNameHandlerMapping -->by controller name as url
3.       SimpleUrlHandlerMapping --> Map pattrens to ID's
4.       CommonsPathHandlerMapping

Command controller
1.       BaseCommandController
2.       AbstarctFormController
3.       AbsarectWizardController
4.       SimplaFormController
5.       AbstarctCommandController

ThrowAway controller
1.       ThrowAway controller

Multi Action Controller
1.       Multi Action Controller

View Resolvers
1.       InternalViewResolver
2.       tilesViewResolver
3.       ...........So many