Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Handler adapter in spring mvc?

I am beginner in Spring MVC. I didn't understand handler adapters clearly. What is a handler adapter and when do I use adapters?

like image 986
techsuri Avatar asked Oct 24 '11 04:10

techsuri


People also ask

What is difference between handler and controller?

Handler is a inclusive i.e. covering all the services details. Controller is an an exclusive implementation.

What is the use of handler mapping in Spring MVC?

HandlerMapping is an interface that defines a mapping between requests and handler objects. While Spring MVC framework provides some ready-made implementations, the interface can be implemented by developers to provide customized mapping strategy.

What are handler methods in Spring?

Class HandlerMethod. Encapsulates information about a handler method consisting of a method and a bean. Provides convenient access to method parameters, the method return value, method annotations, etc. The class may be created with a bean instance or with a bean name (e.g. lazy-init bean, prototype bean).

What is a handler method?

The handler method returns a Boolean value. This value indicates whether Dynamo should continue processing the rest of the page after this handler has finished. If false is returned, Dynamo does not process any remaining values after calling the handler, nor serves the rest of the page.


2 Answers

A HandlerMapping maps a method to a URL, so the DispatcherServlet knows which method should be invoked by a specific request. Then the DispatcherServlet use a HandlerAdapter to invoke the method.

Why DispatcherServlet does not invoke a method directly?

Because there are many ways to invoke a method, like annotation, xml etc. HandlerAdapter de-couples the DispatcherServlet and the invoked actions.

like image 140
user2807219 Avatar answered Sep 22 '22 09:09

user2807219


This section of the Spring docs discusses the default adapters and how they relate to annotation configuration.

Briefly, handler adapters decide which controller (and method) to call for a request.

like image 24
Dave Newton Avatar answered Sep 25 '22 09:09

Dave Newton