Understanding DispatcherHandler
DispatcherHandler
, a front controller in Spring WebFlux, is what DispatcherServlet
is in the Spring MVC framework. DispatcherHandler
contains an algorithm that makes use of special components – HandlerMapping
(maps requests to the handler), HandlerAdapter
(a DispatcherHandler
helper to invoke a handler mapped to a request), and HandlerResultHandler
(a palindrome of words, for processing the result and forming results) – for processing requests. The DispatcherHandler
component is identified by a bean named webHandler
.
It processes requests in the following way:
- A web request is received by
DispatcherHandler
. DispatcherHandler
usesHandlerMapping
to find a matching handler for the request and uses the first match.- It then uses the respective
HandlerAdapter
to process the request, which exposes theHandlerResult
(return value after processing). The return value could be one of the following –ResponseEntity
,ServerResponse...