Spring MVC
Spring MVC
(Model-View-Controller)
LAHIRU
LIYANAPATHIRANA
PAGE 2/21
LAHIRU
LIYANAPATHIRANA
PAGE 3/21
LAHIRU
LIYANAPATHIRANA
PAGE 4/21
LAHIRU
LIYANAPATHIRANA
PAGE 5/21
LAHIRU
LIYANAPATHIRANA
PAGE 8/21
LAHIRU
LIYANAPATHIRANA
PAGE 9/21
LAHIRU
LIYANAPATHIRANA
PAGE 11/21
LAHIRU
LIYANAPATHIRANA
PAGE 12/21
DispatcherServlet
The DispatcherServlet is the central
component in Spring MVC architecture. It
is designed around the Front Controller
pattern.
DispatcherServlet
Collaborates with the HandlerMapping to
find the relevant controller for the request.
LAHIRU
LIYANAPATHIRANA
PAGE 14/21
WebApplicationContext
The WebApplicationContext extends the
plain ApplicationContext to support web
applications.
HandlerMapping
The HandlerMapping maps the incoming
requests to the specific controller
methods. It determines which controller
should be used for the given request URL.
LAHIRU
LIYANAPATHIRANA
PAGE 15/21
HandlerAdapter
Acts as a bridge between the
DispatcherServlet and the Controller. It
invokes the Controller picked by the
HandlerMapping. It allows the
DispatcherServlet to invoke methods on
the controller regardless of how the
controller is implemented.
Controller
The Controllers are special classes
annotated with the @Controller. The
controller is responsible for processing
user requests and returning the
appropriate responses.
LAHIRU
LIYANAPATHIRANA
PAGE 16/21
RestController
The @RestController is a specialized
version of the @Controller annotation used
for creating RESTful web services.
Model
The Model represents the data and
business logic of the application.
LAHIRU
LIYANAPATHIRANA
PAGE 17/21
ModelAndView
The ModelAndView is a holder for both the
model and the view in a Spring MVC
application and is used by the controller
to return both model data and view name
to the DispatcherServlet.
ViewResolver
The ViewResolver maps logical view
names returned by controllers to actual
view implementations such as JSPs. It can
be configured via bean names or property
files.
View
The View is responsible for rendering the
model data to the user. It receives data
from the model and presents it in the
given format. Spring MVC supports various
view technologies like JSP, Thymeleaf, and
FreeMarker.
HandlerInterceptor
The HandlerInterceptor performs
operations before and after a request is
processed by the controller. This is useful
for cross-cutting concerns like logging,
security checks, or modifying the model.
HandlerExceptionResolver
The HandlerExceptionResolver handles
exceptions thrown during the request
process. It provides a centralized
exception-handling mechanism and allows
developers to define custom responses or
views when exceptions occur.
MultipartResolver
The MultipartResolver handles the file
uploads and parses multipart request data
making it easier to handle file uploads. It
supports various file upload libraries and
configurations.
LAHIRU
LIYANAPATHIRANA
PAGE 20/21
LocaleResolver
The LocaleResolver resolves the user's
locale to provide internationalization
support.
ThemeResolver
The ThemeResolver resolves the theme of
the application, allowing for dynamic
theme changes.
LAHIRU
LIYANAPATHIRANA
PAGE 7/7
LAHIRU
LIYANAPATHIRANA