HandlerMapping and HandlerAdapter
HandlerMapping and HandlerAdapter are good for rest service testing.
The strategy interface HandlerAdapter takes the role of invoking handler methods selected by some HandlerMapping.
If a HandlerMapping selects a controller, but not a specific method, then the HandlerAdapter also selects the handler method.
DispatcherServlet invokes controllers through HandlerAdapter strategy objects.
This allows for different types of controllers use different method invokation strategies. and URL mapping strategies are possible.
Installing new types of handler invokation strategies requires an appropriate HandlerAdapter bean to be registered.
When multiple HandlerAdapter are installed, the DispatcherServlet will invoke all to check the first that supports the handler object provided by the HandlerMappingstrategy. The first HandlerAdapter that supports the handler object (controller or method) is used to invoke the handler.
Spring MVC supports several types of controllers, including: annotation defined controllers (with @Controller), the WebFlow FlowExecutor etc.
AnnotationMethodHandlerAdapter adapts HTTP requests to handler methods annotated with @RequestMapping. It introspects required input arguments for handlers, and interprets output values. This the HandlerAdapter configured by default.
The AnnotationMethodHandlerAdapter can be used with controller with multiple handler methods in a variety of powerful ways.
<mvc:annotation-driven/> in spring
<mvc:annotation-driven /> declares explicit support for annotation-driven MVC controllers
The tag will configure two beans DefaultAnnotationHandlerMapping and AnnotationMethodHandlerAdapter so that you do not need to declare them in context config file.
find more information from the spring documents: