Spring HandlerAdapters

Please see this tutorial for an introduction to Spring MVC. In this tutorial we describe the various HandlerAdapter classes available in Spring

HandlerAdapter

HandlerAdapter is responsible for actually invoking the handler. The handler is of type Object and hence the dispatcher servlet can handle any Handler type using the HandlerAdapter. Spring provides certain HandlerAdapters that can handle specific handler interfaces.

SimpleServletHandlerAdapter

This adapter allows using the Servlet Interface. The adapter calls the service method of the Servlet. This adapter is not registered by default and needs to be registered in the DispatcherServlet as a bean. All handler beans that implement the Servlet interface are automatically handled by this adapter.

SimpleControllerHandlerAdapter

Adapter for handlers that implement the Controller interface

HttpRequestHandlerAdapter

Handles org.springframework.web.HttpRequestHandler interface. The HttpRequestHandler is used for handler that process HttpRequests. This interface is generally used to generate binary responses and does not have a ModelAndView return type. The spring remoting classes such as HttpInvokerServiceExporter and HessianServiceExporter implement this interface.

AnnotationMethodHandlerAdapter

This adapter maps Handler methods based on HTTP paths, HTTP methods and request parameters. The request parameters are bound through @RequestParam annotation. Note that this Adapater is deprecated in spring 3.2 in favour of RequestMappingHandlerAdapter.

RequestMappingHandlerAdapter

This adapter supports Handler of type HandlerMethod. This adapter is used with RequestMappingHandlerMapping and is the new class introduced in Spring 3.1. custom Resolvers can be set using

public void setCustomArgumentResolvers(List argumentResolvers) {
		this.customArgumentResolvers = argumentResolvers;
}




Leave a Comment