Spring MVC request and response flow explanation
- Request will be received by
DispatcherServlet
. DispatcherServlet
will take the help ofHandlerMapping
and get to know the@Controller
class name associated with the given request.- So request transfer to the
@Controller
, and then@Controller
will process the request by executing appropriate methods and returnsModelAndView
object (contains Model data and View name) back to the DispatcherServlet - Now
DispatcherServlet
send the model object to theViewResolver
to get the actual view page. - Finally,
DispatcherServlet
will pass the Model object to the View page to display the result.
Spring Flow First Request from JSP/HTML will hit the dispacher servlet, Based on the xml file it will go to particular controller, After going to controller it search for request mapping , based on request mapping it will go to the particular method and follows instructions and takes the model and view and give it to view resolver via dispacher servlet and view resolver will display the view.