SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Spring MVC
Presentation by
Hung Nguyen Huy
Content
1. HTTP Servlet (Review)
2. What is Spring MVC?
3. MVC Architecture
4. Request Processing Workflow in Spring MVC
5. Spring Web Application Context
6. Spring MVC Configuration
7. Important Annotations
8. Summary
HTTP Servlet (Review)
HTTP Servlets
● Are Java classes that run on Web
Servers to dynamically process HTTP
requests and construct HTTP
responses.
● Deployed inside a Servlet Container
which run on a Web Server.
● Tomcat is a popular Servlet Container.
Servlets Architecture
● Servlets act as a middle layer between a
Web browser and databases or
applications on the Web Server.
● The following diagram shows the
position of Servlets in a Web Application
What is Spring MVC ?
What is Spring MVC?
Modules of Spring Framework on the Web layer:
● Web module provides basic web-oriented integration
features and the initialization of the IoC container
using servlet listeners and a web application context.
● Servlet module contains Spring MVC
implementation for web applications.
What is Spring MVC ? (cont.)
● A web framework built on the Servlet API.
● Provides Model-View-Controller (MVC) architecture and ready
components that can be used to develop flexible and loosely coupled web
applications.
● Request-driven, designed around a central Servlet that dispatches
requests to controllers - the DispatcherServlet.
MVC
MVC (Model-View-Controller)
Introduced by Trygve Reenskaug at Xerox Parc in 1979.
MVC (Model-View-Controller)
● An architectural pattern commonly used
for developing user interfaces.
● An application is divided into 3
interconnected parts:
○ Model - Responsible for managing data
of the application.
○ View - Responsible for displaying the
model data to user.
○ Controller - Responsible for processing
user requests and building an
appropriate model and passes it to the
view for rendering.
Request Processing Workflow
in Spring MVC
Request Processing Workflow (High Level)
The request processing workflow in Spring Web MVC (high level)
DispatcherServlet
● Spring MVC is designed around a central
servlet named DispatcherServlet.
● DispatcherServlet acts as a central entry
point to the Spring MVC application.
● Every request is handled by
DispatcherServlet.
● DispatcherServlet is an expression of
the Front Controller pattern.
The request processing workflow in Spring Web MVC (high level)
Controllers
● The Front Controller’s job is to
determine a suitable handler capable of
performing the actual processing.
● Handlers are Spring MVC Controllers.
● The selected Controller interacts with
the service layer; the relevant data are
collected in a model.
● When the Controller has finished
processing, the Front Controller
determines which view to render.
The request processing workflow in Spring Web MVC (high level)
View
● When the Controller has finished
processing, the Front Controller
determines which view to render.
● The Front Controller passes the model
to the view which is finally which is
finally rendered on the browser.
The request processing workflow in Spring Web MVC (high level)
Request Processing Workflow (Details Level)
1. DispatcherServlet receives the request.
2. DispatcherServlet dispatches the task of selecting an
appropriate controller to HandlerMapping. HandlerMapping
selects the Controller which is mapped to the incoming request
URL and returns the (selected Handler) and Controller to
DispatcherServlet.
3. DispatcherServlet dispatches the task of executing of business
logic of Controller to HandlerAdapter.
4. HandlerAdapter calls the business logic process of Controller.
5. Controller executes the business logic, sets the processing
result in Model and returns the logical name of view to
HandlerAdapter.
6. DispatcherServlet dispatches the task of resolving the View
corresponding to the View name to ViewResolver.
ViewResolver returns the View mapped to View name.
7. DispatcherServlet dispatches the rendering process to
returned View.
8. View renders Model data and returns the response.
Web Application Context
Web Application Context
● DispatcherServlet expects a WebApplicationContext,
an extension of a plain ApplicationContext, for its own
configuration.
● WebApplicationContext has a link to the
ServletContext and Servlet it is associated with.
● The root WebApplicationContext typically contains
infrastructure beans such as data repositories and
business services which are inherited and could be
overridden in the Servlet WebApplicationContext.
● Servlet WebApplicationContext contains web-related
beans: such as controllers, handler mappings,...
Spring MVC Configurations
Spring MVC Configurations
Spring MVC supports 2 type of configurations:
● XML Configuration
● Java-based Configuration
Important annotations
Important annotations
Some important annotations which are used in a Spring MVC application.
● @Controller and @RestController
● @RequestMapping
○ @GetMapping, @PostMapping, @PutMapping and @DeleteMapping
● @RequestParam, @PathVariable
● @RequestBody
● @ResponseBody
Summary

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Core
Spring CoreSpring Core
Spring Core
 
Spring jdbc
Spring jdbcSpring jdbc
Spring jdbc
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Spring boot
Spring bootSpring boot
Spring boot
 
Servlets
ServletsServlets
Servlets
 
Express js
Express jsExpress js
Express js
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
 

Ähnlich wie Spring MVC Framework

Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desaijinaldesailive
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Naresh Chintalcheru
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892Tuna Tore
 
quickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcquickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcjorgesimao71
 
Lecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdfLecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdfLê Thưởng
 
Unit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptxUnit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptxAbhijayKulshrestha1
 
Spring mvc
Spring mvcSpring mvc
Spring mvcHui Xie
 
Introduction to Struts 1.3
Introduction to Struts 1.3Introduction to Struts 1.3
Introduction to Struts 1.3Ilio Catallo
 

Ähnlich wie Spring MVC Framework (20)

Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Mvc
MvcMvc
Mvc
 
Asp.net,mvc
Asp.net,mvcAsp.net,mvc
Asp.net,mvc
 
Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
quickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcquickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvc
 
Spring MVC 3.0 Framework
Spring MVC 3.0 FrameworkSpring MVC 3.0 Framework
Spring MVC 3.0 Framework
 
Lecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdfLecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdf
 
Unit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptxUnit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptx
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Dispatcher
DispatcherDispatcher
Dispatcher
 
React JS .NET
React JS .NETReact JS .NET
React JS .NET
 
Introduction to Struts 1.3
Introduction to Struts 1.3Introduction to Struts 1.3
Introduction to Struts 1.3
 

Kürzlich hochgeladen

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 

Kürzlich hochgeladen (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 

Spring MVC Framework

  • 2. Content 1. HTTP Servlet (Review) 2. What is Spring MVC? 3. MVC Architecture 4. Request Processing Workflow in Spring MVC 5. Spring Web Application Context 6. Spring MVC Configuration 7. Important Annotations 8. Summary
  • 4. HTTP Servlets ● Are Java classes that run on Web Servers to dynamically process HTTP requests and construct HTTP responses. ● Deployed inside a Servlet Container which run on a Web Server. ● Tomcat is a popular Servlet Container.
  • 5. Servlets Architecture ● Servlets act as a middle layer between a Web browser and databases or applications on the Web Server. ● The following diagram shows the position of Servlets in a Web Application
  • 7. What is Spring MVC? Modules of Spring Framework on the Web layer: ● Web module provides basic web-oriented integration features and the initialization of the IoC container using servlet listeners and a web application context. ● Servlet module contains Spring MVC implementation for web applications.
  • 8. What is Spring MVC ? (cont.) ● A web framework built on the Servlet API. ● Provides Model-View-Controller (MVC) architecture and ready components that can be used to develop flexible and loosely coupled web applications. ● Request-driven, designed around a central Servlet that dispatches requests to controllers - the DispatcherServlet.
  • 9. MVC
  • 10. MVC (Model-View-Controller) Introduced by Trygve Reenskaug at Xerox Parc in 1979.
  • 11. MVC (Model-View-Controller) ● An architectural pattern commonly used for developing user interfaces. ● An application is divided into 3 interconnected parts: ○ Model - Responsible for managing data of the application. ○ View - Responsible for displaying the model data to user. ○ Controller - Responsible for processing user requests and building an appropriate model and passes it to the view for rendering.
  • 13. Request Processing Workflow (High Level) The request processing workflow in Spring Web MVC (high level)
  • 14. DispatcherServlet ● Spring MVC is designed around a central servlet named DispatcherServlet. ● DispatcherServlet acts as a central entry point to the Spring MVC application. ● Every request is handled by DispatcherServlet. ● DispatcherServlet is an expression of the Front Controller pattern. The request processing workflow in Spring Web MVC (high level)
  • 15. Controllers ● The Front Controller’s job is to determine a suitable handler capable of performing the actual processing. ● Handlers are Spring MVC Controllers. ● The selected Controller interacts with the service layer; the relevant data are collected in a model. ● When the Controller has finished processing, the Front Controller determines which view to render. The request processing workflow in Spring Web MVC (high level)
  • 16. View ● When the Controller has finished processing, the Front Controller determines which view to render. ● The Front Controller passes the model to the view which is finally which is finally rendered on the browser. The request processing workflow in Spring Web MVC (high level)
  • 17. Request Processing Workflow (Details Level) 1. DispatcherServlet receives the request. 2. DispatcherServlet dispatches the task of selecting an appropriate controller to HandlerMapping. HandlerMapping selects the Controller which is mapped to the incoming request URL and returns the (selected Handler) and Controller to DispatcherServlet. 3. DispatcherServlet dispatches the task of executing of business logic of Controller to HandlerAdapter. 4. HandlerAdapter calls the business logic process of Controller. 5. Controller executes the business logic, sets the processing result in Model and returns the logical name of view to HandlerAdapter. 6. DispatcherServlet dispatches the task of resolving the View corresponding to the View name to ViewResolver. ViewResolver returns the View mapped to View name. 7. DispatcherServlet dispatches the rendering process to returned View. 8. View renders Model data and returns the response.
  • 19. Web Application Context ● DispatcherServlet expects a WebApplicationContext, an extension of a plain ApplicationContext, for its own configuration. ● WebApplicationContext has a link to the ServletContext and Servlet it is associated with. ● The root WebApplicationContext typically contains infrastructure beans such as data repositories and business services which are inherited and could be overridden in the Servlet WebApplicationContext. ● Servlet WebApplicationContext contains web-related beans: such as controllers, handler mappings,...
  • 21. Spring MVC Configurations Spring MVC supports 2 type of configurations: ● XML Configuration ● Java-based Configuration
  • 23. Important annotations Some important annotations which are used in a Spring MVC application. ● @Controller and @RestController ● @RequestMapping ○ @GetMapping, @PostMapping, @PutMapping and @DeleteMapping ● @RequestParam, @PathVariable ● @RequestBody ● @ResponseBody