SlideShare uma empresa Scribd logo
1 de 21
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 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 Advantages and Components
Spring MVC Advantages and Components
Spring MVC Advantages and Components
Spring MVC Advantages and Components
Spring MVC Advantages and Components
Spring MVC Advantages and Components

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & Actuators
 
Spring AOP
Spring AOPSpring AOP
Spring AOP
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Maven et industrialisation du logiciel
Maven et industrialisation du logicielMaven et industrialisation du logiciel
Maven et industrialisation du logiciel
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Introduction à spring boot
Introduction à spring bootIntroduction à spring boot
Introduction à spring boot
 
Java Spring
Java SpringJava Spring
Java Spring
 
Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Hibernate jpa
Hibernate jpaHibernate jpa
Hibernate jpa
 

Semelhante a Spring MVC Advantages and Components

Spring MVC framework features and concepts
Spring MVC framework features and conceptsSpring MVC framework features and concepts
Spring MVC framework features and conceptsAsmaShaikh478737
 
quickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcquickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcjorgesimao71
 
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 MVCJosh Juneau
 
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
 
The Spring Framework
The Spring FrameworkThe Spring Framework
The Spring FrameworkMax Goff
 
The Spring Framework
The Spring FrameworkThe Spring Framework
The Spring FrameworkMax Goff
 
Spring mvc
Spring mvcSpring mvc
Spring mvcHui Xie
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesAaron Jacobson
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework Serhat Can
 

Semelhante a Spring MVC Advantages and Components (20)

Spring MVC framework features and concepts
Spring MVC framework features and conceptsSpring MVC framework features and concepts
Spring MVC framework features and concepts
 
Spring MVC 3.0 Framework
Spring MVC 3.0 FrameworkSpring MVC 3.0 Framework
Spring MVC 3.0 Framework
 
Spring mvc 2.0
Spring mvc 2.0Spring mvc 2.0
Spring mvc 2.0
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
quickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcquickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvc
 
MVC architecture
MVC architectureMVC architecture
MVC architecture
 
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
 
Mvc
MvcMvc
Mvc
 
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
 
Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
 
Aspnet mvc
Aspnet mvcAspnet mvc
Aspnet mvc
 
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
 
The Spring Framework
The Spring FrameworkThe Spring Framework
The Spring Framework
 
The Spring Framework
The Spring FrameworkThe Spring Framework
The Spring Framework
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Asp.net,mvc
Asp.net,mvcAsp.net,mvc
Asp.net,mvc
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development services
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 

Último

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Último (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

Spring MVC Advantages and Components

  • 1.
  • 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.
  • 4.
  • 5.
  • 6.
  • 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

Notas do Editor

  1. Convention over configuration=attempts to decrease the number of decisions
  2. <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring-servlet.xml</param-value> </init-param>
  3. @controller class
  4. Spring-servlet.xml