Help the world stop coronavirus! Stay home!

Prev Next

Spring / Spring MVC Interview questions

What is DispatcherServlet in Spring MVC Framework?

Spring web MVC framework is request-driven, flows through the central Servlet, DispatcherServlet that handles all the HTTP requests and responses. Spring's DispatcherServlet is completely integrated with the Spring IoC container so it allows you to use every feature that Spring has along with Request handling.

After receiving an HTTP request, DispatcherServlet gets helps from the HandlerMapping (configuration files) to resolve and call the appropriate Controller. The Controller takes the request and calls the appropriate service methods and set model data and then returns view name to the DispatcherServlet. The DispatcherServlet will take help from ViewResolver to resolve the defined view for the request. Once view is finalized, The DispatcherServlet passes the model data to the view which is finally rendered on the browser.

<web-app>
  <display-name>SpringMVC Demo App</display-name>
   
  <servlet>
        <servlet-name>springMVC</servlet-name>
            <servlet-class>
                org.springframework.web.servlet.DispatcherServlet
            </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
 
    <servlet-mapping>
        <servlet-name>springMVC</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
     
</web-app>

By default, DispatcherServlet resolves its configuration file using <servlet_name>-servlet.xml. For example, with the above web.xml file, DispatcherServlet will look for springMVC-servlet.xml file in classpath.

DispatcherServlet is the front controller in Spring MVC that intercepts every requests and then dispatches/forwards it to an appropriate controller.

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

What is Spring MVC framework? Advantages of Spring MVC framework over other MVC framework. Explain the request flow and its lifecycle in Spring MVC. What is DispatcherServlet in Spring MVC Framework? Spring MVC Framework: What is ContextLoaderListener? What is the difference between ApplicationContext and WebApplicationContext in Spring MVC? Can we have multiple Spring configuration files in Spring MVC? What are the Spring MVC Annotations? What is a Controller in Spring MVC framework? What is the default scope of Spring MVC controllers? Sping MVC - pass model between controllers. Difference Between @RequestParam and @PathVariable in Spring MVC. Explain Interceptors in Spring MVC framework. What is view Resolver pattern and how does it work in Spring MVC? Advantages of Spring MVC over Struts. What is ModelAndView in Spring MVC Framework? What are the different Controller implementations in Spring MVC framework? What is a MultipartResolver in Spring MVC framework? How do I handle exceptions in Spring MVC Framework? How do I handle views in Spring MVC using XML? How to create Controller in Spring MVC? Spring MVC: How to access values from Model in JSP? How to configure DispatcherServlet without web.xml in Spring MVC? What is the role of @EnableWebMvc in Spring MVC? How do I create a Spring MVC controller without a view? How do I return a string from the Spring MVC controller without a view? Explain @ResponseBody annotation in Spring MVC. Explain @RequestBody annotation in Spring MVC. How do I quickly resolve MVC RequestMapping calling wrong controller method? What does request.getParameter return when the parameter does not exist in Spring MVC/Servlet? RestTemplate: How do you resolve SSLHandShakeException? How do I map the JSON field name to a different Java class property name? How do I configure JNDI DataSource in Spring Web Application? How to implement localization in Spring MVC applications? How does Spring MVC provide validation support? Explain MultipartResolver in Spring framework? What is the front controller class of Spring MVC? Explain Spring MVC Interceptor. Advantage of using HandlerInterceptorAdapter in Spring MVC framework. How to start Spring MVC using spring boot? How do I configure DispatcherServlet without using web.xml in Spring MVC? How do I configure Spring MVC view in @Configuration class without spring XML? Is transaction managed at DAO or Service layer in Spring? Difference between Spring MVC and Spring Web Flow. Use of BindingResult interface in Spring MVC. What is resource-ref in web.xml used for? How JNDI lookup differs between Tomcat and weblogic server? How to enable browser caching of static resources (JS, CSS) with Spring MVC? Why Java web apps has dot(.) do extensions? What is @RequestMapping annotation in Spring MVC? How do I configure Spring MVC to eliminate Path-Based Vulnerability? Difference between Spring Web MVC and Spring WebFlux. What is HTTP multipart request? What is content negotiation in Spring MVC? Difference between RequestMapping and GetMapping in Spring MVC/Spring Boot.
Show more question and Answers...

Spring Data Access

Comments & Discussions