Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Struts2 MVC architecture


May 15, 2021 Struts2


Table of contents


Model -View -Controller, commonly referred to as MVC, is a software design model for developing web applications. The software design pattern consists of three parts:

  • Model - belongs to the underlying foundation of software design pattern and is mainly responsible for data maintenance.
  • View -- This part is responsible for presenting all or part of the data to the user.
  • Controller - Controls the interaction between models and views through software code.
MVC is popular because it distinguishes between the logical and user interface layers of an application and supports the separation of development concerns. I n MVC mode, after the controller receives all requests from the application, the model is called to prepare the data required for the view, which then uses the data provided by the controller to eventually generate a visual response. The abstract concept of MVC can be expressed in the following graphics:

Struts2 MVC architecture

Model

The model is primarily responsible for managing the application's data, and it updates its own data by responding to requests from the view and instructions from the controller.

View

A special data format that is presented is triggered by the controller's instructions. They are scripts based on template systems such as JSP, ASP, phP, and are easier to integrate with AJAX technology.

Controller

The controller is responsible for responding to user input and performing interactions with data model objects. T he controller performs business operations to modify the state of the data model after receiving and confirming the input.

Struts2 is an MVC-based framework. In the next chapter, let's look at how to use MVC in Struts2.