Friday, 18 December 2015

Spring MVC

By
Spring MVC

Model View Controller

MVC  is simply a guideline which say how should we write code having a UI
A typical web application developed using servelt looks like this


Client request for web page to the application and then based on url the request is mapped to a perticular servlet,the servelt process the request and send back response in form of HTML or JSP along with the data to the client’s browser.In the same way a typical application developed using JSP render the request.

Many people in IT industry aruges that  Web applications developed using both ways is not a better approach.

As in both case two thing mix together  i:e html code and java code as this is not handy and need both UI and java developer o have knowldege of both.
Lets think of a case when u you wishes to change entire look and fell of your application,it will make difficult to UI developer to make changes instantly due to the java code mix with html and as a result for UI developer and Business developre take much time to make changes.
This problem is resolved by MCV,MVC  separates the Presentation layer (UI code ) from Business logic and provided a generic guideline
It say an application should be divided into three components :
Model :  Represents data
View:      Represents Presentation part
Controller:  Manages the application flow and perform some services to produce Model which is passed to View
Flow of application :

Request come to application and controller analysis it and makes a decision to call an appropriate Business service to get  the Model. Once it receive the Model it passes  on this Model to View component in order to form the final output response is sent back to the client browser.
In case of Java, A Model is a java object which is having some properties and having getters and setter methods (Beans) POJO classes .View is HTML or JSP code displaying the data retrived from Model object and Business Services are also java object which perform some services

 Real life example of how this overall concept of MVC works:


Retailer have cake shop and having three rooms  each bakes different kind of cakes  and have two employees which have different skills for decorating cake,So if customer make request for a cake retailer identity the type of cake send request to specific  room for making cake and when cake is ready then it come back to retailer and according to client request about  decoration retailer send cake for decoration to specific employee and then cake is ready with decoration part it come again to retailer and finally to customer by retailer and customer is happy.
Thanks for reading ,I hope you have got the concept of MVC .I will come with other tutorial soon









0 comments :

Post a Comment