Home > Java, Spring > How MVC belongs to only Presentation Layer?

How MVC belongs to only Presentation Layer?

Spring MVC in simple terms:

It is a presentation framework, you may have doubt “How MVC belongs to only presentation layer”.

MVC Framework:

View and Controller belongs to Presentation Layer as Controller takes the URL and directs to appropriate View based on the given URL.

 MVC Flow:

  1. Request comes to the controller, controller decides is there any business logic to be implemented for this request or not.
  2.  If no business logic required it will redirect to the appropriate View. Ex: if we are requesting a login form no business logic required here so controller directly redirect login.jsp.
  3. If business logic required to the particular request it will call the appropriate Service class to process the request. Based on the service object response, controller redirects to the appropriate view.
  4. In the view if there is any data is to be shown, then the data will be taken from appropriate model.

With the above diagram View and Controller directly interacting with Presentation Layer.

And model is used by View to show the data.

So MVC belongs to Presentation Layer

MVC in Three tier architecture:

In three tier architecture we have Presentation Tier, Middle Tier, Data Access Tier, simply we can call Presentation layer, Service layer  and DAO Layer.

Presentation layer interacts with the Service layer and Service layer interacts with DAO layer.

The Flow will be like this:

  1. Request  comes to controller and controller decides whether this request needs any business logic to be implemented or not
  2. If no it simply returns a view.
  3. If yes it interacts with Service Layer and Service Layer interacts with DAO Layer
  4. Later the based on the response from Service Layer appropriate View will be shown by the Controller.

Spring recommends the same model can be used for presentation layer, In Struts we have form beans as presentation layer model. But in Spring we can use the same model across all the Three Layers.

Advertisement
Categories: Java, Spring
  1. karibasappa
    September 20, 2012 at 5:34 pm

    since model will be updated by DAO and service layer , so we can say model belongs to all the layers…right?

    • rameshcharykotha
      September 20, 2012 at 5:42 pm

      Exactly KB, model spans through all the layers. But its not the case with sturts. In sturts we have Form Beans as presentation model.
      Thanks for your valuable comment.

  2. karibasappa
    September 21, 2012 at 5:19 pm

    ok thanks dude……:)

  3. November 20, 2016 at 8:59 am

    best i have seen so far on MVC2

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: