MVC instance Application

Source: Internet
Author: User

MVC is the abbreviation for Model-view-controller, the model-view-controller. MVC is a design pattern,

It divides the application into three core modules: models, views, and controllers, each of which handles its own tasks.

1. Model

A, the model is the main part of the application, and the model represents business data and business logic.

b, a model can provide data for multiple views.

C, because the code applied to the model can be reused by multiple views only once, it improves the reusability of the code.

2. View:

Simply put the Java code on the page to implement the display.

In detail, the view is the interface that the user sees and interacts with, with the following functions:

A. View displays relevant data to the user

b, accept the user's input

C, do not carry out any actual business processing

3. Controllers (Controller)

A, the controller accepts the user's input and invokes the model and view to complete the user's needs.

B, the Controller accepts and decides which model component is called to process the request, and then decides which view to call to display the data returned by the model processing.

Accept requests---> GET request Parameters---> Call the DAO method---> May put a DAO method's placement in Request---> forwarding or redirecting pages

In the actual process, the equivalent of a a.jsp sending a GET request to the servlet requires all student information, and then the servlet's Doget () method calls

The model layer DAO's GetAll () method returns the student's list object, puts the resulting object in the request, and then requests forwarding to b.jsp,b.jsp.

The data sent over is traversed and displayed. The DAO object is of course called the GetAll () method, returning the value to list.

MVC instance Application

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.