DispatcherServlet
A front controller is defined as “a controller which handles all requests for a Web Application.” DispatcherServlet (actually a servlet) is the front controller in Spring MVC that intercepts every request and then dispatches/forwards requests to an appropriate controller.
|
Web.xml with DispatcherServlet
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
|
Hints
org.springframework.web.servlet.DispatcherServlet class used to controls the request and response with given url pattern. *.htm. Application context bean and wiring bean xml file has to create with the -servlet.xml suffix. So that for above example dispatcher-servlet.xml is the name of the application context xml file.
|