Why does Spring mvc need HandlerAdapter?

Spring mvc two components: HandlerMapping and HandlerAdapter;
HandlerMapping can already help us match the specific controller (Controller)?
then why do you need HandlerAdapter??


adapter pattern, there are many kinds of controller (Controller), one of which is annotated with @ Controller, and you can also write a servlet as controller, so use the adapter to adapt. Take a look at how many subclasses HandlerAdapter has. Each subclass adapts to a certain type of controller. With HandlerAdapter, you only need to call the handle method, shielding the inconsistent details, otherwise you will have to if else if else

in the DispatcherServlet.
Menu