SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

Spring MVC
Spring MVCSpring MVC
Spring MVC
Aaron Schram
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Purbarun Chakrabarti
 
Spring boot
Spring bootSpring boot
Spring boot
Pradeep Shanmugam
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
Emprovise
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
Jeevesh Pandey
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Pravin Pundge
 
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
Hitesh-Java
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
Santosh Kumar Kar
 
Spring boot
Spring bootSpring boot
Spring boot
Gyanendra Yadav
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
Rohit Gupta
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jiayun Zhou
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
Jeevesh Pandey
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By StepJava Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
Ni
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
Remo Jansen
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Hùng Nguyễn Huy
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
07.pallav
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
Spring jdbc
Spring jdbcSpring jdbc
Spring jdbc
Harshit Choudhary
 

Similar to 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
jinaldesailive
 
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
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
nagarajupatangay
 
Mvc
MvcMvc
Mvc
Furqan Ashraf
 
Asp.net,mvc
Asp.net,mvcAsp.net,mvc
Asp.net,mvc
Prashant Kumar
 
Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
rohitkumar1987in
 
Spring Web Presentation 123143242341234234
Spring Web Presentation 123143242341234234Spring Web Presentation 123143242341234234
Spring Web Presentation 123143242341234234
horiadobrin
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
Fajar Baskoro
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
Fajar Baskoro
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
Tuna Tore
 
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
Tuna Tore
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
Ashton Feller
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
Surbhi Panhalkar
 
quickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcquickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvc
jorgesimao71
 
Spring MVC 3.0 Framework
Spring MVC 3.0 FrameworkSpring MVC 3.0 Framework
Spring MVC 3.0 Framework
Ravi Kant Soni ([email protected])
 
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
Lê Thưởng
 
Unit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptxUnit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptx
AbhijayKulshrestha1
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Hui Xie
 
Dispatcher
DispatcherDispatcher
Dispatcher
RAHUL VUTUKURI
 
React JS .NET
React JS .NETReact JS .NET
React JS .NET
Jennifer Estrada
 
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
jinaldesailive
 
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
 
Spring Web Presentation 123143242341234234
Spring Web Presentation 123143242341234234Spring Web Presentation 123143242341234234
Spring Web Presentation 123143242341234234
horiadobrin
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
Tuna Tore
 
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
Tuna Tore
 
quickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcquickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvc
jorgesimao71
 
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
Lê Thưởng
 
Unit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptxUnit 38 - Spring MVC Introduction.pptx
Unit 38 - Spring MVC Introduction.pptx
AbhijayKulshrestha1
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Hui Xie
 
Ad

Recently uploaded (20)

EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
wareshashahzadiii
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Shift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software DevelopmentShift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software Development
SathyaShankar6
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
wareshashahzadiii
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Shift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software DevelopmentShift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software Development
SathyaShankar6
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Ad

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