How to do it...

Let us build a simple web application using the Spring MVC concept:

  1. Open web.xml and register the main servlet handler of our Spring MVC application, which is org.springframework.web.servlet.DispatcherServlet.
<servlet> 
  <servlet-name>ch02</servlet-name> 
  <servlet-class> 
    org.springframework.web.servlet.DispatcherServlet 
  </servlet-class> 
  <load-on-startup>1</load-on-startup> 
</servlet> 
<servlet-mapping> 
  <servlet-name>ch02</servlet-name> 
  <url-pattern>*.html</url-pattern> 
</servlet-mapping> 
Be cautious with the <url-pattern> in web.xml because it is where DispatcherServlet picks the correct format for its request URLs. The pattern *.html means the main servlet will recognize all URL paths with a view extension of .html.
  1. In the ...

Get Spring 5.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.