Spring MVC…

Introduction to Spring Web MVC framework

How Spring Web MVC Really Works

  • the dispatcher servlet first receives the request.
  • the dispatcher servlet consults the helping and invokes the controller associated with the request.
  • the controller processes the request by calling the appropriate service methods and returns a modelAndViewobject to the dispatcher servlet. the modelAndViewobject object contains the model data and the view name.
  • the dispatcher servlet sends the view name to a view resolver to find the actual view to invoke.
  • now, the dispatcher servlet will pass the model object to view to render the result.
  • the view, with the help of the model data, will render the result back to the user.

Defining a Controller

  • We will define the required business logic inside a service method. We can call another method inside this method as per requirement.
  • Based on the business logic defined, we will create a model within this method. We can use setter different model attributes and these attributes will be accessed by the view to present the final result. This example creates a model with its attribute “message”.
  • A defined service method can return a String, which contains the name of the view to be used to render the model. This example returns “hello” as a logical view name.

Spring MVC Model Class

Creating Views

Conclusion

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Flutter Thursday 13: Building a User Registration and Login Process with provider and external API

Understanding How Emails Actually Work Behind the Scenes — A Beginner-Friendly Guide

Table of Contents

Kubernetes Debug Story — How NOT to run a privileged container

#8 — The ESP32 Weather Station

ETSI Open Source MANO Starter Guide

How to craft an effective sprint goal?

Extracting patches from Whole Slide Images(WSI)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ajit Kumar Singh

Ajit Kumar Singh

More from Medium

CS373 Spring 2022: Anthony Hoang

Loops and Nested Loops

My Journey started with DLithe for Java Full Stack Developer.

Lombok Experimental Annotations