34. MVC framework summary

MVC (Model -View-View-Controller Controller) is a design pattern.
            M (Model) in Java Web means JavaBean. In addition to its properties and fields, JavaBean can also have behaviors and events. JavaBean can It is understood as a normal Java object . Java ordinary objects are all objects that conform to the Java specification, which are completely different from entity classes. Business logic and data access should be placed in the Model layer, that is, V is responsible for displaying data, and Controler does not do business logic except forwarding . The real logical transactions, data access, and even algorithms are put into the Model.
          Controller means controller. The so-called controller is to forward user requests to the model layer, and return the result to an intermediate layer displayed by the interface layer after processing. So what does the controller do? Let's not talk about it. Let's first look at the general definitions of these three layers in Java Web. Generally, in Java Web, JSP acts as V, Servlet acts as C, and JavaBean acts as M. What does the Servlet do here? Accept the input, go to the Model layer for processing, save the processing result and forward it to JSP, and then display the data. So its function is the basic function of the controller, it just manages the forwarding and goes back and forth between V and M.

               V is View ( view layer), mainly used to display data and submit data

            MVC does not regard business logic access as two layers, which is the main difference between using a three-tier architecture or MVC to build a program. Of course. Model is also mentioned in the three-tier architecture, but the concept of Model in the three-tier architecture is different from the concept of Model in MVC. The typical Model layer in the "three-tier" is composed of entity classes, while in MVC, it is Composed of business logic and access data.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325541570&siteId=291194637