1 - What is Dispatcher Servlet in Spring? | Setup a web application in #SpringMVC #DispatcherServlet



0
9941

#DispatcherServlet #SpringFramework #SpringMVC For help and support - https://www.buymeacoffee.com/almightyjava ================== DispatcherServlet is the class which manages the entire request handling process. Like a normal servlet DispatcherServlet also needs to be configured in the web deployment Descriptor (web.XML).By default, DispatcherServlet will look for a name dispatcher-servlet.XML to load the Spring MVC configuration. ================== Spring's web MVC framework is, like many other web MVC frameworks, request-driven, designed around a central servlet that dispatches requests to controllers and offers other functionality that facilitates the development of web applications. Spring's DispatcherServlet however, does more than just that. It is completely integrated with the Spring IoC container and as such allows you to use every other feature that Spring has. The request processing workflow of the Spring Web MVC DispatcherServlet is illustrated in the following diagram. The pattern-savvy reader will recognize that the DispatcherServlet is an expression of the “Front Controller” design pattern (this is a pattern that Spring Web MVC shares with many other leading web frameworks). ================== After you set up a DispatcherServlet, and a request comes in for that specific DispatcherServlet, the DispatcherServlet starts processing the request as follows: --- The WebApplicationContext is searched for and bound in the request as an attribute that the controller and other elements in the process can use. It is bound by default under the key DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE. --- The locale resolver is bound to the request to enable elements in the process to resolve the locale to use when processing the request (rendering the view, preparing data, and so on). If you do not need locale resolving, you do not need it. --- The theme resolver is bound to the request to let elements such as views determine which theme to use. If you do not use themes, you can ignore it. --- If you specify a multipart file resolver, the request is inspected for multiparts; if multiparts are found, the request is wrapped in a MultipartHttpServletRequest for further processing by other elements in the process. (See Section 15.8.2, “Using the MultipartResolver” for further information about multipart handling). --- An appropriate handler is searched for. If a handler is found, the execution chain associated with the handler (preprocessors, postprocessors, and controllers) is executed in order to prepare a model or rendering. --- If a model is returned, the view is rendered. If no model is returned, (may be due to a preprocessor or postprocessor intercepting the request, perhaps for security reasons), no view is rendered, because the request could already have been fulfilled. ================== For more information read the blog - https://almightyjava.wordpress.com/2016/12/27/what-is-dispatcher-servlet/

Published by: Almighty Java Published at: 5 years ago Category: آموزشی