27. Spring MVC -Handler Mappings

Handler Mappings

1.BeanNameUrlHandlerMapping
·         It is the default handler
·         we not need to configure in  spring-servlet.xml
·         it will search by URL

2.SimpleUrlHandlerMapping
·         Here we have to use class id of Controller
·         pass that class id to SimpleUrlHandlerMapping as properties
·         SimpleUrlHandlerMapping has a property mapping
·         we have to pass urls in that mappings

3.ControllerClassNamelHandler
·         Here we don’t need to configure any thing
·         ControllerClassNamelHandler searches the controller by matching URL automatically
·         Here we need to make sure URL name and Controller names must me same pattern

4. Multiple Spring-servlet.xml using Init Parameters
·         we have to pass xml files to DispatcherServlet as <init-param>
·         param name must be contextConfigLocation
·         param values   as /WEB-INF/sp.xml (any no.of xmls)

5..Multiple Spring-servlet.xml using context Parameters
·         we have to pass xml files to DispatcherServlet as <context-param>
·         we have to configure <listener>
·         param name must be contextConfigLocation
·         param values   as /WEB-INF/sp.xml (any no.of xmls)

6. Abstract Controller
  • AbstractController contains a method p modelAndView handleRequestIntrernal(rq,res)
  • it's similar like handleRequest() method in controller class

7.ParameterizeViewController
  • It has setViewName() setter method
  • we have to configure successpages in xml in value attribute
  • ParameterizeViewController have getView() method to get the page

8.UrlFileName Controller
  • using req it's read the url
  • it's add the url name to modelandview object
  • based on action name it try to find view pages
  • It's uses forward functionality

9. MultiAction Controller
1.       If two or more actions handles same controller, we use MultiAction Controller
2.       we have write our own methods, it must return modelandView with req,res
3.       method signatures are same as handleRequest
4.       method name should equal to action names
5.       if method and action names are different we use methodResolvers

Post a Comment

Thank You

Previous Post Next Post