MVC Summary (servlet)

Source: Internet
Author: User

Here I will use my blog example written using Servlet, and then use the functions provided by the files in the example to correspond to the corresponding part of the MVC pattern. I will not describe the details here.

Let me briefly introduce the MVC mode:


M is the exponential data model, V refers to the user interface, and C is the controller. The purpose of using MVC is to separate the implementation code of M and V, so that the same program can use different forms of representation. The purpose of C is to ensure synchronization between m and V. Once M changes, V should be updated synchronously.

The most typical MVC is the JSP + servlet + JavaBean mode. My blog example uses this mode.


Below I will correspond to MVC Based on my example:


First, a full file directory:

Here is the file required by my project.

V (User Interface ):




Only a part of JSP files are listed here. The JSP file corresponds to V (User Interface). We can enter information on the interface, such as search information and user login.


C (Controller ):


I am using Servlet here (I will not go into details about some of the Servlet's usage and configuration details here. There is a lot of information on the Internet .)


Servlet is used for command and calling methods.

The main workflow of servlet is two methods: doget () and dopost. Call different methods in the doget () method based on different situations.



M (Data Model ):


Equivalent to JavaBean




Dao contains specific methods, such as connecting to the database for searching and updating.

In form, object attributes and corresponding get and set methods are stored.

Tool contains some tool classes, such as character replacement and database connection.


After this blog study, I have summarized my understanding of MVC.:MVC is equivalent to playing a music, C is the conductor, V is the performer and its instrument, M is the audience, the conductor directs the performers to play, the audience to enjoy.



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.