Hey guys in this post, you will learn about Spring MVC and its architectural diagram with flow diagram.
Read More:
- Check the Complete Spring MVC Tutorials
- Check the Complete JSP Tutorials
- Check the Complete Spring Boot Tutorials [100+ Examples]
- Check the Complete Spring Boot and Thymeleaf Tutorial
- Check the Complete AWS Tutorial
- Check the Complete JavaServer Faces (JSF) Tutorial
- Check the Complete Spring Data JPA Tutorial
- Check the Complete Spring Security Tutorial
- Check the Javascript Projects for Beginners
- Check the Spring Boot JdbcTemplate Tutorials
Table of Contents
What is Spring MVC?
- Spring MVC is a framework for building web applications in Java
- It is based on the Model-View-Control design pattern
- It leverages features of the core Spring framework such as Inversion of control and dependency injection
Model-View-Controller
Below is the architectural flow diagram of Spring MVC
- Browser sends a request to the server. Server takes that request, process it and send it to the Front controller
- Front controller is a Dispatcher Servlet, its the job is the send the request to the appropriate controller
- Controller code is the one written by developers, which contains the business logic
- Controller will then prepare the model and send it to the Front controller for further processing
- Front controller then send that model to the view template, which is contains the HTML code and data which needs to be displayed in the web page.
Controller
- Controller classes are created by developers
- Contains business logic and it handles the request
- It store and retrieve the data from database and other services
- It will write the data to the model
- It will send the data to the appropriate view template
Model
- Model is just a java object contains the data
- It will help us the store and retrieve the data from database or web service
View Template
- Spring MVC is flexible, it supports many view templates
- Most commonly used view templates are JSP and Thymeleaf
- Developer creates the view template to display the data present in Model
Spring MVC Benifits
- It is the best way of building web applications in Java
- It leverages a set of reusable UI components
- It will help us to manage application state for web requests
- It process the form data by validating, converting etc,
- It is very flexible to configure the view layer with other view templates.
Additional Resources
- Read more about Spring MVC documentation on their official website
That’s it for this post, if you like this post, please share this post with your friends and collogues and also share this on your social media profiles.