SlideShare a Scribd company logo
Spring mvc
Advantage
• Separate roles - The Spring MVC separates each role, where the model object, controller, command object,
view resolver, DispatcherServlet, validator, etc. can be fulfilled by a specialized object.
• Light-weight - It uses light-weight servlet container to develop and deploy your application.
• Powerful Configuration - It provides a robust configuration for both framework and application classes
that includes easy referencing across contexts, such as from web controllers to business objects and
validators.
• Rapid development - The Spring MVC facilitates fast and parallel development.
• Reusable business code - Instead of creating new objects, it allows us to use the existing business objects.
• Easy to test - In Spring, generally we create JavaBeans classes that enable you to inject test data using the
setter methods.
• Flexible Mapping - It provides the specific annotations that easily redirect the page.
Advantage(Components)
• Inversion Of Control (IOC): In Spring Framework, loose coupling is achieved using Inversion of Control.
The objects give their own dependencies instead of creating or looking for dependent objects.
• Aspect Oriented Programming (AOP): By separating application business logic from system services,
Spring Framework supports Aspect Oriented Programming and enables cohesive development.
• Container: Spring Framework creates and manages the life cycle and configuration of application objects.
• Transaction Management: For transaction management, Spring framework provides a generic abstraction
layer. It is not tied to J2EE environments and it can be used in container-less environments.
• JDBC Exception Handling: The JDBC abstraction layer of the Spring Framework offers an exception
hierarchy, which simplifies the error handling strategy.
• MVC Framework: Spring Framework is a MVC web application framework. This framework is configurable
via interfaces and accommodates multiple view technologies.
Spring mvc
Spring mvc
Spring mvc
Spring MVC Taxonomy
 DispatcherServlet
 Spring provided front controller
 Controls request routing
 Controllers
 User created POJO
 Standard Spring beans
 View
 Responsible for rendering a response
Core MVC components
 ModelAndView
 stores model data
 associates a view to the request
 can be a view implementation or a logical name
 ViewResolver
 Used to map logical view names to view implementations
 HandlerMapping
 Used by DispatcherServlet to map requests to controllers
Dispatcher Servlet
• Used to handle all incoming requests and route them through Spring
• Uses customizable logic to determine which controllers should handle which
requests
• Forwards all responses to through view handlers to determine the correct
views to route responses
• Exposes all beans defined in Spring to controllers for dependency injection
Model
• A Model is used in Spring MVC to pass objects from the controller tier up
into the view
• A Model is really just a java.util.Map
• You can add attributes to a Model and they will be put on the request as
attributes and available in the applications PageContext .
• In Spring you can simply pass back a Map orone of two Spring specific
classes; ModelMap or Model
Spring Views
 Extensive Support
 JSP, Velocity, FreeMarker, JasperReporters
 PDF, Excel
 Views are mapped by ViewResolvers
Spring MVC Annotations
 @Controller
 Stereotype used to “Controller” of MVC
 Scanned for RequestMappings
 Convention over configuration
 @RequestMapping
 Annotates a handler method for a request
 Very flexible
 @RequestParam
 Annotates that a method parameter should be bound to a web request parameter
 @SessionAttributes
 Marks session attributes that a handler uses
Spring MVC Parameters
 Parameters can be
 Request / response / session
 WebRequest
 InputStream
 OutputStream
 @RequestParam etc..
Spring MVC Return Types
 Return types
 ModelAndView Object
 Model Object
 Map for exposing model
 View Object
 String which is a view name
 Void… if method wrote the response content directly
Handler Mappings
 DefaultAnnotationHandlerMapping
 annotation based - @Controller
 SimpleUrlHandlerMapping
 configuration based
 still works with annotations
 ControllerClassNameHandlerMapping
 UrlFileNameViewController
 views without a controller
Spring mvc
Spring mvc
Spring mvc
Spring mvc
Spring mvc
Spring mvc
Ad

More Related Content

What's hot (20)

Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
Naphachara Rattanawilai
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Purbarun Chakrabarti
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
Jeevesh Pandey
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou
 
Entity Framework Core
Entity Framework CoreEntity Framework Core
Entity Framework Core
Kiran Shahi
 
Introduction to Swagger
Introduction to SwaggerIntroduction to Swagger
Introduction to Swagger
Knoldus Inc.
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
Dzmitry Naskou
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jaran Flaath
 
Spring annotation
Spring annotationSpring annotation
Spring annotation
Rajiv Srivastava
 
Spring Core
Spring CoreSpring Core
Spring Core
Pushan Bhattacharya
 
Swagger UI
Swagger UISwagger UI
Swagger UI
Walaa Hamdy Assy
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample application
Antoine Rey
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
Thibaud Desodt
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Spring boot
Spring bootSpring boot
Spring boot
Gyanendra Yadav
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
Dzmitry Naskou
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
zeeshanhanif
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jiayun Zhou
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
PradeepDyavannanavar
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
Jeevesh Pandey
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou
 
Entity Framework Core
Entity Framework CoreEntity Framework Core
Entity Framework Core
Kiran Shahi
 
Introduction to Swagger
Introduction to SwaggerIntroduction to Swagger
Introduction to Swagger
Knoldus Inc.
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
Dzmitry Naskou
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample application
Antoine Rey
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
Thibaud Desodt
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
Dzmitry Naskou
 

Similar to Spring mvc (20)

Spring MVC framework features and concepts
Spring MVC framework features and conceptsSpring MVC framework features and concepts
Spring MVC framework features and concepts
AsmaShaikh478737
 
Spring MVC 3.0 Framework
Spring MVC 3.0 FrameworkSpring MVC 3.0 Framework
Spring MVC 3.0 Framework
Ravi Kant Soni ([email protected])
 
Spring Web Presentation 123143242341234234
Spring Web Presentation 123143242341234234Spring Web Presentation 123143242341234234
Spring Web Presentation 123143242341234234
horiadobrin
 
Spring mvc 2.0
Spring mvc 2.0Spring mvc 2.0
Spring mvc 2.0
Rudra Garnaik, PMI-ACP®
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
Ashton Feller
 
quickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcquickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvc
jorgesimao71
 
MVC architecture
MVC architectureMVC architecture
MVC architecture
baabtra.com - No. 1 supplier of quality freshers
 
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
 
Mvc
MvcMvc
Mvc
Furqan Ashraf
 
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Josh Juneau
 
Module 5.ppt.............................
Module 5.ppt.............................Module 5.ppt.............................
Module 5.ppt.............................
Betty333100
 
Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
rohitkumar1987in
 
Aspnet mvc
Aspnet mvcAspnet mvc
Aspnet mvc
Hiep Luong
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
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
 
The Spring Framework
The Spring FrameworkThe Spring Framework
The Spring Framework
Max Goff
 
The Spring Framework
The Spring FrameworkThe Spring Framework
The Spring Framework
Max Goff
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Hui Xie
 
Asp.net,mvc
Asp.net,mvcAsp.net,mvc
Asp.net,mvc
Prashant Kumar
 
Spring MVC framework features and concepts
Spring MVC framework features and conceptsSpring MVC framework features and concepts
Spring MVC framework features and concepts
AsmaShaikh478737
 
Spring Web Presentation 123143242341234234
Spring Web Presentation 123143242341234234Spring Web Presentation 123143242341234234
Spring Web Presentation 123143242341234234
horiadobrin
 
quickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcquickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvc
jorgesimao71
 
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 EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Josh Juneau
 
Module 5.ppt.............................
Module 5.ppt.............................Module 5.ppt.............................
Module 5.ppt.............................
Betty333100
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
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
 
The Spring Framework
The Spring FrameworkThe Spring Framework
The Spring Framework
Max Goff
 
The Spring Framework
The Spring FrameworkThe Spring Framework
The Spring Framework
Max Goff
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Hui Xie
 
Ad

Recently uploaded (20)

Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from AnywhereAutomation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Lynda Kane
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from AnywhereAutomation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Lynda Kane
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Ad

Spring mvc

  • 2. Advantage • Separate roles - The Spring MVC separates each role, where the model object, controller, command object, view resolver, DispatcherServlet, validator, etc. can be fulfilled by a specialized object. • Light-weight - It uses light-weight servlet container to develop and deploy your application. • Powerful Configuration - It provides a robust configuration for both framework and application classes that includes easy referencing across contexts, such as from web controllers to business objects and validators. • Rapid development - The Spring MVC facilitates fast and parallel development. • Reusable business code - Instead of creating new objects, it allows us to use the existing business objects. • Easy to test - In Spring, generally we create JavaBeans classes that enable you to inject test data using the setter methods. • Flexible Mapping - It provides the specific annotations that easily redirect the page.
  • 3. Advantage(Components) • Inversion Of Control (IOC): In Spring Framework, loose coupling is achieved using Inversion of Control. The objects give their own dependencies instead of creating or looking for dependent objects. • Aspect Oriented Programming (AOP): By separating application business logic from system services, Spring Framework supports Aspect Oriented Programming and enables cohesive development. • Container: Spring Framework creates and manages the life cycle and configuration of application objects. • Transaction Management: For transaction management, Spring framework provides a generic abstraction layer. It is not tied to J2EE environments and it can be used in container-less environments. • JDBC Exception Handling: The JDBC abstraction layer of the Spring Framework offers an exception hierarchy, which simplifies the error handling strategy. • MVC Framework: Spring Framework is a MVC web application framework. This framework is configurable via interfaces and accommodates multiple view technologies.
  • 7. Spring MVC Taxonomy  DispatcherServlet  Spring provided front controller  Controls request routing  Controllers  User created POJO  Standard Spring beans  View  Responsible for rendering a response
  • 8. Core MVC components  ModelAndView  stores model data  associates a view to the request  can be a view implementation or a logical name  ViewResolver  Used to map logical view names to view implementations  HandlerMapping  Used by DispatcherServlet to map requests to controllers
  • 9. Dispatcher Servlet • Used to handle all incoming requests and route them through Spring • Uses customizable logic to determine which controllers should handle which requests • Forwards all responses to through view handlers to determine the correct views to route responses • Exposes all beans defined in Spring to controllers for dependency injection
  • 10. Model • A Model is used in Spring MVC to pass objects from the controller tier up into the view • A Model is really just a java.util.Map • You can add attributes to a Model and they will be put on the request as attributes and available in the applications PageContext . • In Spring you can simply pass back a Map orone of two Spring specific classes; ModelMap or Model
  • 11. Spring Views  Extensive Support  JSP, Velocity, FreeMarker, JasperReporters  PDF, Excel  Views are mapped by ViewResolvers
  • 12. Spring MVC Annotations  @Controller  Stereotype used to “Controller” of MVC  Scanned for RequestMappings  Convention over configuration  @RequestMapping  Annotates a handler method for a request  Very flexible  @RequestParam  Annotates that a method parameter should be bound to a web request parameter  @SessionAttributes  Marks session attributes that a handler uses
  • 13. Spring MVC Parameters  Parameters can be  Request / response / session  WebRequest  InputStream  OutputStream  @RequestParam etc..
  • 14. Spring MVC Return Types  Return types  ModelAndView Object  Model Object  Map for exposing model  View Object  String which is a view name  Void… if method wrote the response content directly
  • 15. Handler Mappings  DefaultAnnotationHandlerMapping  annotation based - @Controller  SimpleUrlHandlerMapping  configuration based  still works with annotations  ControllerClassNameHandlerMapping  UrlFileNameViewController  views without a controller

Editor's Notes

  • #13: Convention over configuration=attempts to decrease the number of decisions
  • #18: <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-servlet.xml</param-value> </init-param>
  • #19: @controller class
  • #20: Spring-servlet.xml