SlideShare a Scribd company logo
copyright © I-Admin
Spring Framework 3.0 MVC
Prepared By:
Ravi Kant Soni
Sr. Software Engineer | ADS-Bangalore
session - 1
copyright © I-Admin
Objectives
 Introduce Spring MVC Module
 Learn about Spring MVC Components
(Dispatcher, Handler mapping, Controller,
View Resolver, View)
copyright © I-Admin
What Is Spring?
copyright © I-Admin
What is Spring?
 Spring is light weight, open source framework begins
developed by Spring Source Company
 Spring 1.0 was released in 2004
 Spring is available on www.springframework.org
 It provides support for JPA, Hibernate, Web services,
Schedulers, Ajax, Struts, JSF and many other
frameworks
copyright © I-Admin
Why use Spring?
 Spring was created to reduce the complexity
observed in Java enterprise application development
 Spring is organised into many modules that offer
various types of assistance to the developer in a host
of application areas
• Spring enables developers to develop enterprise-
class applications using POJOs
• Testing an application written with Spring is simple
because environment-dependent code is moved into
this framework
copyright © I-Admin
By the way, just what is MVC?
 Model-View-Controller or MVC is an architectural
pattern used in development of applications.
– Model encapsulates the raw data
– Controller responds to events, and instruct the model and view to
perform actions based on events
– View render information supplied by model in a form suitable for
user interaction.
copyright © I-Admin
MVC Architecture
copyright © I-Admin
Spring MVC Architecture
 Based on existing Servlet/JSP technology
copyright © I-Admin
Spring MVC Components
 DispatcherServlet responsible for intercepting the
request and dispatching for specific urls.
 Controller responsible for processing user requests
and building appropriate model and passes it to the
view for rendering
 View interface represents presentation logic and is
responsible for rendering content
 ModelAndView class objects encapsulates view and
model linking
 Model encapsulates the application data, will consist
of POJO
copyright © I-Admin
DispatcherServlet
 Used to handle all incoming requests and route them
through Spring
 Also responsible to initialize the frameworks
components which are used to process the request
at various stages
 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 to
 DispatcherServlet Architecture uses the Front
Controller Design Pattern
copyright © I-Admin
DispatcherServlet Architecture
copyright © I-Admin
DispatcherServlet Mapping
 Request that are to be handled by DispatcherServlet
are to be mapped using a URL mapping in web.xml
config file.
 Each DispatcherServlet has its own
WebApplicationContext
copyright © I-Admin
DispatcherServlet in web.xml
 Dispatcher Servlet named "spring" that will intercept all urls to this web
application
 <servlet-mapping> tag indicates what URLs will be handled by the which
DispatcherServlet
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
copyright © I-Admin
Spring Configuration
 By default Spring looks for a servletname -servlet.xml file in /WEB-INF
 For the previous example we would need to create a file in /WEB-INF named
spring-servlet.xml
<beans xmlns …….>
<mvc:annotation-driven/>
<context:component-scan base-package="com.iadmin.spring" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
copyright © I-Admin
Spring Configuration cont..
 <mvc:annotation-driven /> tells Spring to support
annotations like @Controller, @RequestMapping
and others that simplify the writing and configuration
of controllers
 InternalResourceViewResolver resolve the view
names, looks for JSPs that match a given view
name in the director /WEB-INF/jsp
 <context:component-scan...> tell Spring where to
automatically detect controllers
copyright © I-Admin
The ‘C’ in MVC
 DispatcherServlet delegates the request to the
controllers to execute the functionality specific to it
 The @Controller annotation indicates that a
particular class serves the role of a controller
 Controller interpret user input and transform this
input into specific model which will be represented to
the user by the view
copyright © I-Admin
The ‘M’ in MVC
 Model is generally defined as a MAP that can
contain objects that are to be displayed in view
 ModelAndView object encapsulates the relations
between view and model and is returned by
corresponding Controller methods
 ModelAndView class use ModelMap that is custom
MAP implementation where values are added in key-
value fashion
copyright © I-Admin
The ‘V’ in MVC
 View Page can be explicitly returned as part of
ModelAndView object by the controller
 In case of mapping logical name of view can be
resolved to particular view page in case
ModelAndView doesn’t contain the view reference
 The view name can be independent of view
technology (without using .jsp in controller) and
resolved to specific technology by using
ViewResolver and render by View
copyright © I-Admin
Defining a Controller
 @Controller annotation defines the class as a
Spring MVC controller
 @RequestMapping annotation is used to map a
URL to either an entire class or a particular handler
method
 DispatcherServlet delegates the request to the
controllers to execute the functionality specific to it
copyright © I-Admin
Defining a Controller cont…
@Controllerpublic
class HelloController{
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String printHello(ModelMap model) {
model.addAttribute("message", "Hello Spring MVC !");
return "hello";
}
}
 The value attribute indicates the URL to which the handler
method is mapped
 The method attribute defines the service method to handle
HTTP GET request
copyright © I-Admin
Creating JSP Views
 Spring MVC supports many types of views for different presentation
technologies. These include - JSPs, HTML, PDF, Excel worksheets, XML,
Velocity templates, XSLT, JSON, Atom and RSS feeds, JasperReports etc
 /WEB-INF/hello/hello.jsp:
<html>
<head>
<title>Hello Spring MVC</title>
</head>
<body>
<h2>${message}</h2>
</body>
</html>
 Here, ${message} is the attribute which we have setup inside the Controller
copyright © I-Admin
Spring vs. Struts
 Struts Framework
– Based on MVC architecture
– View – JSPs, ActionForms
– Controller – ActionServlet, Actions
 Spring Framework
– DispatcherServlet - Spring’s Front Controller implementation
– View- JSP’s
– ViewResolver - Maps logical View names to actual View
implementations
– HandlerMapping-Strategy interface used by DispatcherServlet for
mapping incoming requests to individual Controllers
copyright © I-Admin
DEMO
copyright © I-Admin
Questions
Thank You
ravikant.soni@i-admin.com

More Related Content

What's hot (20)

PPT
A Deeper look into Javascript Basics
Mindfire Solutions
 
PDF
Spring Boot
Pei-Tang Huang
 
PDF
Getting started with Spring Security
Knoldus Inc.
 
PPTX
Spring Boot
Jiayun Zhou
 
PDF
5 collection framework
Minal Maniar
 
PPTX
Spring boot
Gyanendra Yadav
 
PDF
Spring boot introduction
Rasheed Waraich
 
PPTX
Introduction to spring boot
Santosh Kumar Kar
 
PDF
Deep Dive Java 17 Devoxx UK
José Paumard
 
PDF
TypeScript - An Introduction
NexThoughts Technologies
 
PPTX
Sharing Data Between Angular Components
Squash Apps Pvt Ltd
 
PDF
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
PDF
Java 8 Stream API. A different way to process collections.
David Gómez García
 
PPTX
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
PDF
AEM Best Practices for Component Development
Gabriel Walt
 
PPTX
Spring boot - an introduction
Jonathan Holloway
 
PDF
Introduction to Spring Boot!
Jakub Kubrynski
 
PPTX
Angular modules in depth
Christoffer Noring
 
PPTX
Hibernate ppt
Aneega
 
A Deeper look into Javascript Basics
Mindfire Solutions
 
Spring Boot
Pei-Tang Huang
 
Getting started with Spring Security
Knoldus Inc.
 
Spring Boot
Jiayun Zhou
 
5 collection framework
Minal Maniar
 
Spring boot
Gyanendra Yadav
 
Spring boot introduction
Rasheed Waraich
 
Introduction to spring boot
Santosh Kumar Kar
 
Deep Dive Java 17 Devoxx UK
José Paumard
 
TypeScript - An Introduction
NexThoughts Technologies
 
Sharing Data Between Angular Components
Squash Apps Pvt Ltd
 
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
Java 8 Stream API. A different way to process collections.
David Gómez García
 
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
AEM Best Practices for Component Development
Gabriel Walt
 
Spring boot - an introduction
Jonathan Holloway
 
Introduction to Spring Boot!
Jakub Kubrynski
 
Angular modules in depth
Christoffer Noring
 
Hibernate ppt
Aneega
 

Viewers also liked (20)

PPT
Spring MVC Basics
Bozhidar Bozhanov
 
PDF
Spring Framework - MVC
Dzmitry Naskou
 
PPTX
Spring MVC framework
Mohit Gupta
 
PDF
Introduction to Spring MVC
Richard Paul
 
PPT
Presentation Spring, Spring MVC
Nathaniel Richand
 
PPTX
Introduction to Spring Framework
Serhat Can
 
PDF
Support de cours Spring M.youssfi
ENSET, Université Hassan II Casablanca
 
PPTX
Introduction to Spring Framework
Dineesha Suraweera
 
PPTX
Spring MVC Architecture Tutorial
Java Success Point
 
PPT
MVC Pattern. Flex implementation of MVC
Anton Krasnoshchok
 
PPT
Spring 3.x - Spring MVC
Guy Nir
 
PDF
Spring MVC - The Basics
Ilio Catallo
 
ODP
Java Spring MVC Framework with AngularJS by Google and HTML5
Tuna Tore
 
PDF
Spring Framework - Core
Dzmitry Naskou
 
PPT
Presentation Spring
Nathaniel Richand
 
DOCX
Диплом Ярош А.
Socreklamanalytics
 
PDF
Matilla Portfolio
Matilla Yuen
 
PPTX
Zed ria presentation
sujiswetha65
 
DOCX
Диплом Пакалина Ю.
Socreklamanalytics
 
PPTX
портфоліо на мк 2013 [автосохраненный] готовий
les1812
 
Spring MVC Basics
Bozhidar Bozhanov
 
Spring Framework - MVC
Dzmitry Naskou
 
Spring MVC framework
Mohit Gupta
 
Introduction to Spring MVC
Richard Paul
 
Presentation Spring, Spring MVC
Nathaniel Richand
 
Introduction to Spring Framework
Serhat Can
 
Support de cours Spring M.youssfi
ENSET, Université Hassan II Casablanca
 
Introduction to Spring Framework
Dineesha Suraweera
 
Spring MVC Architecture Tutorial
Java Success Point
 
MVC Pattern. Flex implementation of MVC
Anton Krasnoshchok
 
Spring 3.x - Spring MVC
Guy Nir
 
Spring MVC - The Basics
Ilio Catallo
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Tuna Tore
 
Spring Framework - Core
Dzmitry Naskou
 
Presentation Spring
Nathaniel Richand
 
Диплом Ярош А.
Socreklamanalytics
 
Matilla Portfolio
Matilla Yuen
 
Zed ria presentation
sujiswetha65
 
Диплом Пакалина Ю.
Socreklamanalytics
 
портфоліо на мк 2013 [автосохраненный] готовий
les1812
 
Ad

Similar to Spring MVC 3.0 Framework (20)

PDF
quickguide-einnovator-7-spring-mvc
jorgesimao71
 
PPTX
Spring MVC framework features and concepts
AsmaShaikh478737
 
ODP
springmvc-150923124312-lva1-app6892
Tuna Tore
 
PPTX
Spring mvc
nagarajupatangay
 
PPTX
Spring mvc
Pravin Pundge
 
PPTX
Spring mvc
Harshit Choudhary
 
PDF
Spring MVC Framework
Hùng Nguyễn Huy
 
PDF
Jinal desai .net
rohitkumar1987in
 
PPTX
Dispatcher
RAHUL VUTUKURI
 
PPTX
Asp.net mvc
erdemergin
 
PDF
Spring MVC introduction HVA
Peter Maas
 
ODP
Spring Portlet MVC
John Lewis
 
PPTX
Spring MVC
Emprovise
 
PDF
Spring mvc 2.0
Rudra Garnaik, PMI-ACP®
 
PPT
MVC
akshin
 
PDF
Spring Framework-II
People Strategists
 
PPTX
MVC 4
Vasilios Kuznos
 
PPTX
Spring Framework
tola99
 
PPT
Struts(mrsurwar) ppt
mrsurwar
 
PPTX
AngularJS = Browser applications on steroids
Maurice De Beijer [MVP]
 
quickguide-einnovator-7-spring-mvc
jorgesimao71
 
Spring MVC framework features and concepts
AsmaShaikh478737
 
springmvc-150923124312-lva1-app6892
Tuna Tore
 
Spring mvc
nagarajupatangay
 
Spring mvc
Pravin Pundge
 
Spring mvc
Harshit Choudhary
 
Spring MVC Framework
Hùng Nguyễn Huy
 
Jinal desai .net
rohitkumar1987in
 
Dispatcher
RAHUL VUTUKURI
 
Asp.net mvc
erdemergin
 
Spring MVC introduction HVA
Peter Maas
 
Spring Portlet MVC
John Lewis
 
Spring MVC
Emprovise
 
Spring mvc 2.0
Rudra Garnaik, PMI-ACP®
 
MVC
akshin
 
Spring Framework-II
People Strategists
 
Spring Framework
tola99
 
Struts(mrsurwar) ppt
mrsurwar
 
AngularJS = Browser applications on steroids
Maurice De Beijer [MVP]
 
Ad

Recently uploaded (20)

PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Digital Circuits, important subject in CS
contactparinay1
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 

Spring MVC 3.0 Framework

  • 1. copyright © I-Admin Spring Framework 3.0 MVC Prepared By: Ravi Kant Soni Sr. Software Engineer | ADS-Bangalore session - 1
  • 2. copyright © I-Admin Objectives  Introduce Spring MVC Module  Learn about Spring MVC Components (Dispatcher, Handler mapping, Controller, View Resolver, View)
  • 4. copyright © I-Admin What is Spring?  Spring is light weight, open source framework begins developed by Spring Source Company  Spring 1.0 was released in 2004  Spring is available on www.springframework.org  It provides support for JPA, Hibernate, Web services, Schedulers, Ajax, Struts, JSF and many other frameworks
  • 5. copyright © I-Admin Why use Spring?  Spring was created to reduce the complexity observed in Java enterprise application development  Spring is organised into many modules that offer various types of assistance to the developer in a host of application areas • Spring enables developers to develop enterprise- class applications using POJOs • Testing an application written with Spring is simple because environment-dependent code is moved into this framework
  • 6. copyright © I-Admin By the way, just what is MVC?  Model-View-Controller or MVC is an architectural pattern used in development of applications. – Model encapsulates the raw data – Controller responds to events, and instruct the model and view to perform actions based on events – View render information supplied by model in a form suitable for user interaction.
  • 8. copyright © I-Admin Spring MVC Architecture  Based on existing Servlet/JSP technology
  • 9. copyright © I-Admin Spring MVC Components  DispatcherServlet responsible for intercepting the request and dispatching for specific urls.  Controller responsible for processing user requests and building appropriate model and passes it to the view for rendering  View interface represents presentation logic and is responsible for rendering content  ModelAndView class objects encapsulates view and model linking  Model encapsulates the application data, will consist of POJO
  • 10. copyright © I-Admin DispatcherServlet  Used to handle all incoming requests and route them through Spring  Also responsible to initialize the frameworks components which are used to process the request at various stages  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 to  DispatcherServlet Architecture uses the Front Controller Design Pattern
  • 12. copyright © I-Admin DispatcherServlet Mapping  Request that are to be handled by DispatcherServlet are to be mapped using a URL mapping in web.xml config file.  Each DispatcherServlet has its own WebApplicationContext
  • 13. copyright © I-Admin DispatcherServlet in web.xml  Dispatcher Servlet named "spring" that will intercept all urls to this web application  <servlet-mapping> tag indicates what URLs will be handled by the which DispatcherServlet <servlet> <servlet-name>spring</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
  • 14. copyright © I-Admin Spring Configuration  By default Spring looks for a servletname -servlet.xml file in /WEB-INF  For the previous example we would need to create a file in /WEB-INF named spring-servlet.xml <beans xmlns …….> <mvc:annotation-driven/> <context:component-scan base-package="com.iadmin.spring" /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </beans>
  • 15. copyright © I-Admin Spring Configuration cont..  <mvc:annotation-driven /> tells Spring to support annotations like @Controller, @RequestMapping and others that simplify the writing and configuration of controllers  InternalResourceViewResolver resolve the view names, looks for JSPs that match a given view name in the director /WEB-INF/jsp  <context:component-scan...> tell Spring where to automatically detect controllers
  • 16. copyright © I-Admin The ‘C’ in MVC  DispatcherServlet delegates the request to the controllers to execute the functionality specific to it  The @Controller annotation indicates that a particular class serves the role of a controller  Controller interpret user input and transform this input into specific model which will be represented to the user by the view
  • 17. copyright © I-Admin The ‘M’ in MVC  Model is generally defined as a MAP that can contain objects that are to be displayed in view  ModelAndView object encapsulates the relations between view and model and is returned by corresponding Controller methods  ModelAndView class use ModelMap that is custom MAP implementation where values are added in key- value fashion
  • 18. copyright © I-Admin The ‘V’ in MVC  View Page can be explicitly returned as part of ModelAndView object by the controller  In case of mapping logical name of view can be resolved to particular view page in case ModelAndView doesn’t contain the view reference  The view name can be independent of view technology (without using .jsp in controller) and resolved to specific technology by using ViewResolver and render by View
  • 19. copyright © I-Admin Defining a Controller  @Controller annotation defines the class as a Spring MVC controller  @RequestMapping annotation is used to map a URL to either an entire class or a particular handler method  DispatcherServlet delegates the request to the controllers to execute the functionality specific to it
  • 20. copyright © I-Admin Defining a Controller cont… @Controllerpublic class HelloController{ @RequestMapping(value = "/hello", method = RequestMethod.GET) public String printHello(ModelMap model) { model.addAttribute("message", "Hello Spring MVC !"); return "hello"; } }  The value attribute indicates the URL to which the handler method is mapped  The method attribute defines the service method to handle HTTP GET request
  • 21. copyright © I-Admin Creating JSP Views  Spring MVC supports many types of views for different presentation technologies. These include - JSPs, HTML, PDF, Excel worksheets, XML, Velocity templates, XSLT, JSON, Atom and RSS feeds, JasperReports etc  /WEB-INF/hello/hello.jsp: <html> <head> <title>Hello Spring MVC</title> </head> <body> <h2>${message}</h2> </body> </html>  Here, ${message} is the attribute which we have setup inside the Controller
  • 22. copyright © I-Admin Spring vs. Struts  Struts Framework – Based on MVC architecture – View – JSPs, ActionForms – Controller – ActionServlet, Actions  Spring Framework – DispatcherServlet - Spring’s Front Controller implementation – View- JSP’s – ViewResolver - Maps logical View names to actual View implementations – HandlerMapping-Strategy interface used by DispatcherServlet for mapping incoming requests to individual Controllers