Learn MVC quickly

Source: Internet
Author: User

the full name of MVC is the abbreviation of the model-view-controller, a software design paradigm, a way to organize code that separates business logic, data, and interface display. Aggregating business logic into a single component does not require rewriting business logic while improving and personalizing the interface and user interaction.
Each part of MVC has its own business functions, as follows: the model is the part of the application that handles the logic of the application's data, which is equivalent to layer d in layer three, which operates on the database. View is the part of the application that handles the display of data, primarily by displaying the data to the user.
a controller is a part of the application that handles user interaction, processes different pages, and returns. This is primarily about how the view and controller interact. The interaction includes two aspects, one is to the controller in the data to the foreground display, to facilitate user observation, 21 is to receive the data sent by the user. 1, first Look first, the data to the foreground to display:in the controller, get the data from the model layer, bind to the variable, (in this data is bound directly) as follows:

The data sent by the controller in the foreground (View) is as follows:

this will run directly, you can see the data passed, the results of the operation are as follows:

2, in this see how to upload the user's data from the view to the controller, specifically as follows:first write the foreground submission code:

because it goes to Acceptdata, it receives the data (LJ, above) from the text box in the form in Acceptdata, as follows:

the code shown in the view is as follows:

This completes the transfer of data from the previous view to the controller with the following results:

Summary: In this section mainly describes how the view and controller is the interaction between the data, in fact, and we have learned about the CS almost, is to pass the data, and then in the data processing. In CS, data is obtained from the interface, and in this the data is obtained from the Web page. The essence is still the same.

Learn MVC quickly

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.