Creating a Spring MVC using an XML-based approach
It is now time to apply all the previous recipes to create a working Spring MVC setup. Applying Inversion of Control and Dependency Injection, our main goal now is to build a working baseline project with an XML-based container running on top of the Servlet container of our Tomcat 9 application server. This recipe will feature MVC components of Spring 5.0 and explain how this MVC works together with the servlet components.
Getting started
Create a new project ch02-web.xml
using STS Eclipse 8.3. Configure the Maven and deployment descriptor as per the recipe, Implementing the Spring Container using XML. Once all configuration errors are bug-fixed, perform the following steps to create a Spring MVC backbone.
How to do it...
Let us build a simple web application using the Spring MVC concept:
- Open
web.xml
and register the main servlet handler of our Spring MVC application, which isorg.springframework.web.servlet.DispatcherServlet
.
<servlet>...