Spring Handler mappings

You can map incoming web requests to appropriate handlers using a handler mapping. DispatcherServlet consults one or more handler mappings to determine which controller the request should be sent to. All handler mapping classes in Spring implement org.springframework.web.servlet.HandlerMapping interface. Spring distribution contains following implementation of HandlerMapping interface.

  • BeanNameUrlHandlerMapping – Maps from URLs to beans with names that start with a slash (“/”). This is the default implementation used by the DispatcherServlet
  • ControllerBeanNameHandlerMapping – This is similar to BeanNameUrlHandlerMapping but doesn’t expect bean names to follow the URL convention: It turns plain bean names into URLs by prepending a slash and optionally applying a specified prefix and/or suffix.
  • ControllerClassNameHandlerMapping – Maps controllers to URLs by using the controllers’ class names as the basis for their URLs. For example:
    HelloWorldController -> /helloworld, /helloworld/*
  • DefaultAnnotationHandlerMapping – Maps request to controller and controller methods that are annotated with @RequestMapping.
  • SimpleUrlHandlerMapping – Maps controllers to URLs using a property collection defined in the Spring application context.

, ,

No comments yet.

Leave a Reply