The MVC architecture and Design pattern of Java EE

Source: Internet
Author: User

At present, most enterprises adopt the structure design and solution of Java technology. For us to study and study the Java EE architecture, it is necessary to understand and master the design method of Java EE architecture and some common patterns; model-View-control (Model-view-control, short MVC) structure is the most common architecture of Java EE application, MVC is primarily useful for interactive Web applications, in particular, there are a large number of pages and multiple customer access and data display; In comparison, a workflow architecture is more applied to process control and less interaction; In addition to architecture, the Java EE design pattern is also helpful for us to solve the application system design.

One, the Java EE Model-View-control (MVC) architecture

Model-view-control structures are an architecture that is widely used by interactive applications. It effectively distinguishes the functional modules in the objects that store and display data to reduce their connectivity, which transforms the traditional input, processing and input models into graphical display user interaction models, or, in other words, a multi-level web business application. The MVC architecture has three levels: model, view, and Control (Controller), each of which has its own functional role, and the MVC architecture is as follows:

Figure 1 MVC Architecture

The model layer is responsible for expressing and accessing business data, performing business logic and operations. In other words, this layer is a real-life function of the software simulation, when the model layer changes, it will inform the view layer and provide the latter access to their own state capabilities, while the control layer can also access its functional functions to complete the relevant tasks.

The view layer is responsible for displaying the contents of the model layer. It obtains data from the model layer and specifies how the data is displayed. When the model layer changes, it is automatically updated. In addition, the view layer transmits the user's input to the controller.

The control layer is responsible for defining the behavior of the application. It can assign a user's request and select the appropriate view for display, and it can interpret the user's input and map them to an executable action in the model layer; In a graphical interface, common user input includes click buttons and menu selections. In Web applications, it includes requests for HTTP GET and post for the web layer, and the control layer can select the next view that can be displayed based on the user's interaction and the results of the model layer's operations, and an application typically sets a control-layer module based on a set of related functions. Even some applications have different control layer settings based on different user types, mainly because different users have different view interactions and choices.

Dividing responsibilities between the model layer, the view layer, and the control layer reduces the duplication of code and makes the application easier to maintain. At the same time, due to the separation of data and business logic, the data processing will become simpler when new sources are added and data display changes.

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.