user983447 user983447 - 1 month ago 9
Java Question

what's difference between Controller and Handler in Spring MVC?

The documentation of Spring MVC sometimes says about "handlers" or "request handlers". For instance, says:

Implementation of the HandlerMapping interface to map from URLs to request handler beans

And sometimes it says about controllers. For instance, there is an interface called org.springframework.web.servlet.mvc.Controller ( ).

My question is: are Controllers and Handlers the same?


Generally speaking, a Controller is Handler, but a Handler doesn't have to be a Controller.

For example, HttpRequestHandler, WebRequestHandler, MessageHandler are all handlers which can work with the DispatcherServlet. ( (@)Controller is a handler for executing a web request and returning a view.)

Shortly, Handler is just a term it isn't a class nor interface. And it is responsable of executing the Mapping.