0% found this document useful (0 votes)
5 views18 pages

Unit4 SpringMVC

The document provides an overview of the Spring MVC framework, which is an open-source Java platform for developing web applications using the Model-View-Controller design pattern. It details the roles of the Model, View, Controller, and DispatcherServlet in handling requests and responses. Additionally, it outlines steps to create a Spring MVC application, including setting up the project, creating controllers, and configuring the server.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views18 pages

Unit4 SpringMVC

The document provides an overview of the Spring MVC framework, which is an open-source Java platform for developing web applications using the Model-View-Controller design pattern. It details the roles of the Model, View, Controller, and DispatcherServlet in handling requests and responses. Additionally, it outlines steps to create a Spring MVC application, including setting up the project, creating controllers, and configuring the server.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Spring Framework Module

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 1


Spring Framework Module

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 2


Working with Spring MVC

Ms. ADITEE MATTOO ADVANCED JAVA PROGRAMMING Unit-3


08/27/2025 3
Spring MVC
• Model - A model contains the data of the application. A data can be a single object
or a collection of objects.
• View - A view represents the provided information in a particular format. Generally,
JSP+JSTL is used to create a view page. The View is responsible for rendering the
model data and in general, it generates HTML output that the client's browser can
interpret.
• Controller - A controller contains the business logic of an application. Here, the
@Controller annotation is used to mark the class as the controller. The Controller is
responsible for processing User Requests and Building Appropriate Model and
passes it to the view for rendering.
• Front Controller - In Spring Web MVC, the DispatcherServlet class works as the
front controller. It is responsible to manage the flow of the Spring MVC application.
27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 4
Spring Web Model-View-Controller
(MVC)

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 5


Working with Spring MVC

Ms. ADITEE MATTOO ADVANCED JAVA PROGRAMMING Unit-3


08/27/2025 6
Spring MVC: Introduction

• Spring MVC framework is an open-source Java platform for developing Java-


based Web applications.
• It follows the Model-View-Controller design pattern.

• It implements all the basic features of a core spring framework like Inversion of
Control, and Dependency Injection.
• It provides an solution to use MVC in spring framework with the help
of DispatcherServlet.
• DispatcherServlet is a class that receives the incoming request and maps it to
the right resource such as controllers, models, and views.

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 7


Working of MVC Framework

1. All the incoming requests are intercepted by the


DispatcherServlet that works as the front controller.

2. The DispatcherServlet then gets an entry of handler


mapping from the XML file and forwards the request to the
controller.

3. The object of Model And View is returned by the controller.

4. The DispatcherServlet checks the entry of the view resolver


in the XML file and invokes the appropriate view
component.

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 8


The DispatcherServlet

• The Spring Web model-view-controller (MVC) framework is designed around a


DispatcherServlet that handles all the HTTP requests and responses. The
request processing workflow of the Spring Web MVC DispatcherServlet is
shown in the following illustration.

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 9


Cont…

• As displayed in the figure, all the incoming request is


intercepted by the DispatcherServlet that works as the front
controller.
• The DispatcherServlet gets an entry of handler mapping
from the XML file and forwards the request to the controller.
• The controller returns an object of ModelAndView.

• The DispatcherServlet checks the entry of view resolver in


the XML file and invokes the specified view component.

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 10


Directory Structure of Spring MVC

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 11


Directory Structure of Spring MVC
using Maven

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 12


Create Your First Spring MVC
Application

Step 0: Setup your project with maven use the required archetype to
get the required folders directory and configure the server with your
project.

Step 2: Create the Controller Class.


Step 3: Provide the name of the controller in the web.xml file
as follows:
DispatcherServlet is the front controller in Spring Web MVC.
Incoming requests for the HTML file are forwarded to the
DispatcherServlet.
Step 4: We have to define the bean in a separate XML file. We have specified
the view components in this file. It is located in the WEB-INF directory.
Step 5: Use JSP to display the message.
Step 6: Start the server and run the project.

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 13


Spring Framework Module

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 14


Reference Documentation

Spring Framework Reference Documentation

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 15


Steps

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 16


Steps

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 17


Thank You

27/08/2025 Ms. Himani Sharma ACSAI0612 Advanced Java Programming 18

You might also like