SlideShare a Scribd company logo
2
Most read
8
Most read
15
Most read
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

More Related Content

PDF
Spring MVC Framework
PDF
Spring MVC
PPTX
Introduction to spring boot
PPTX
Spring boot
PDF
Spring Boot
ODP
Spring User Guide
PDF
Spring Framework - Core
PDF
Introduction to Spring Framework
Spring MVC Framework
Spring MVC
Introduction to spring boot
Spring boot
Spring Boot
Spring User Guide
Spring Framework - Core
Introduction to Spring Framework

What's hot (20)

PPTX
Spring Boot
PPTX
Springboot Microservices
PPTX
Introduction to Spring Boot
PPTX
Spring boot
PPTX
Spring Boot Tutorial
PDF
Spring boot introduction
PPTX
Linq to sql
PPTX
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
PPTX
Spring Security 5
PDF
Microservices with Java, Spring Boot and Spring Cloud
PPTX
Spring boot - an introduction
PPT
Maven Introduction
PDF
Spring Framework
PPTX
Spring Framework
PPTX
Introduction to Spring Framework
PPTX
Spring boot Introduction
PPTX
Java Spring Framework
PPTX
Spring data jpa
PPTX
Spring Web MVC
PDF
Spring annotation
Spring Boot
Springboot Microservices
Introduction to Spring Boot
Spring boot
Spring Boot Tutorial
Spring boot introduction
Linq to sql
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Spring Security 5
Microservices with Java, Spring Boot and Spring Cloud
Spring boot - an introduction
Maven Introduction
Spring Framework
Spring Framework
Introduction to Spring Framework
Spring boot Introduction
Java Spring Framework
Spring data jpa
Spring Web MVC
Spring annotation
Ad

Similar to Spring mvc (20)

PPTX
Spring MVC framework features and concepts
PPT
PPTX
Spring Web Presentation 123143242341234234
PDF
Spring mvc 2.0
PPTX
MVC Framework
PDF
quickguide-einnovator-7-spring-mvc
PDF
Design & Development of Web Applications using SpringMVC
PPTX
PDF
Java EE 8 Web Frameworks: A Look at JSF vs MVC
PPT
Module 5.ppt.............................
PDF
Jinal desai .net
PPTX
Aspnet mvc
ODP
springmvc-150923124312-lva1-app6892
ODP
Java Spring MVC Framework with AngularJS by Google and HTML5
PDF
The Spring Framework
PDF
The Spring Framework
PPTX
Spring mvc
PPT
Asp.net,mvc
PPT
Asp.net mvc
Spring MVC framework features and concepts
Spring Web Presentation 123143242341234234
Spring mvc 2.0
MVC Framework
quickguide-einnovator-7-spring-mvc
Design & Development of Web Applications using SpringMVC
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Module 5.ppt.............................
Jinal desai .net
Aspnet mvc
springmvc-150923124312-lva1-app6892
Java Spring MVC Framework with AngularJS by Google and HTML5
The Spring Framework
The Spring Framework
Spring mvc
Asp.net,mvc
Asp.net mvc
Ad

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
KodekX | Application Modernization Development
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
cuic standard and advanced reporting.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Cloud computing and distributed systems.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Weekly Chronicles - August'25 Week I
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The AUB Centre for AI in Media Proposal.docx
Spectral efficient network and resource selection model in 5G networks
Chapter 3 Spatial Domain Image Processing.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
KodekX | Application Modernization Development
Programs and apps: productivity, graphics, security and other tools
Building Integrated photovoltaic BIPV_UPV.pdf
Understanding_Digital_Forensics_Presentation.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
cuic standard and advanced reporting.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Machine learning based COVID-19 study performance prediction
Cloud computing and distributed systems.
Advanced methodologies resolving dimensionality complications for autism neur...
20250228 LYD VKU AI Blended-Learning.pptx

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