What is MVC?
It is a framework for building web applications in java which is based on MODEL-VIEW-CONTROLLER design pattern which leverages the features of core SpringBoot framework (IOC,DI)
Spring Boot MVC, make it easy to create MVC apps with very clear delineations and interactions. The Model represents formal underlying data constructs that the View uses to present the user with the look and feel of the application. A Controller is like a traffic cop. It receives incoming requests (traffic) and routes that traffic according to your application’s configuration.
To understand the basic architecture of the SpringBoot MVC see the below image:
Components of an MVC Application:
A set of webpages to layout UI components
A collection of Spring Beans(Controller , Services , etc)
Configuration (XML,ANNOTAIONS or JAVA)
SpringBoot MVC Front Controller :
This front controller known as DispatcherServlet
Part of the spring framework
Already developed by spring Dev team
What we will create?
Model Objects(Orange)
View templates(Dark Green)
Controller classes(Yellow)
Controller:
A controller contains the business logic of an application. Here, the @Controller annotation is used to mark the class as the controller.
Code created by developer
Contains your business logic
Handle the request
Store/Retrieve data(db,web service)
Place data in Model
Send to appropriate view template
Model:
A model contains the data of the application. A data can be a single object or a collection of objects.Contains your data
Store / Retrieve data via backend systems
database , webservice etc
Place your data in Model
Data can be any Java Object/Collection
View:
A view represents the provided information in a particular format. Generally, JSP+JSTL is used to create a view page. Although spring also supports other view technologies such as Apache Velocity, Thymeleaf and FreeMarker.
Other view templates supported
Thymeleaf , Groovy
Velocity , FreeMarker etc.
MVC Advantages:
The SpringBoot way of building web app UIs in java
Leverage a set of reusable UI components
Help manage application state for web requests
Process form data : validation , Conversion etc.
Flexible configuration for the view layer
How does CodersArts helps you ?
CodersArts provide :
Spring boot assignment Help
Help in development Projects
Mentorship from Experts Live 1:1 session
Course and Project completions
CourseWork help
コメント