What is MVC and what

Source: Internet
Author: User

Why do I need MVC?

Earliest Javaweb development: servlet==java+ "HTML", Problem: stitching strings in servlets too cumbersome

Later appeared jsp:==html+java nested Java code in Html, problem: page and logic too mixed

resulting in: The Birth of MVC!

MVC is an architectural pattern that does not introduce new functions in itself, which is to guide us to make the Web application structure well

Features: independent of function

Goal: Separating logic from the page

MVC pattern: Model, view, control: Models, views, controllers

1: Model: Contains business logic and business data for an application

2: View: Contains the output form of the application, namely: page or interface

3: Controller: Responsible for coordinating the model and view;

Select which model to invoke to handle the business based on user requests

and finally which view to answer for the user!

  

Models and views in MVC are decoupled and decoupled, and the same model can correspond to many different views

Specific features:

Model:

Package Application Status---------> Data encapsulation

Response status Query----------> Get Data

Exposing the functionality of your app-----------> logic Layer API

View:

Provides HTML form for user request-------> man-Machine interaction

Request update-------> Trigger events for a model

Generating HTML responses-------> Presentation Data

Controller:

Receive and validate data from HTTP requests--------> Collect data and encapsulate data

Map user data to updates to the model--------> invoke the Logical Layer API

Select the view to use for the response---------> select the next page based on the return value

Pure JSP applications

Without MVC, the system structure diagram is as follows:

  

This structure is not very good, in the JSP page write too much code, especially control code, business and logic

is too mixed, so you need to introduce a middle-tier----controller that specifically handles the control code

The standard MVC build diagram is as follows:

  

  

What is MVC and what

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.