What is the Dispatcherservlet function in Spring?

Asked

Viewed 934 times

1

What is the purpose of it? it is recommended to use spring-boot to make all spring xml settings automatically?

1 answer

1


Servlet

The work of DispatcherServlet is to take a requested URI and find the right combination of the handler (usually methods in the controller classes) and views (usually Jsps) that match to the form of the page or resource supposed to be found in that location.

I may have :

  • an archive /WEB-INF/jsp/pages/Home.jsp.
  • a method in the class

    @RequestMapping(value="/pages/Home.html")
    private ModelMap buildHome() {
        return somestuff;
    }
    

Dispatcher Servlet is the piece that "knows" to call the method when the browser requests the page, combines the results with the JSP file and generates an HTML document.

References and complete answer in English:

https://stackoverflow.com/questions/2769467/what-is-dispatcher-servlet-in-spring/2769523#2769523

Documentation:

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/DispatcherServlet.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.