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

Struts2 architecture


May 15, 2021 Struts2


Table of contents



From a high-level perspective, Struts2 is an MVC-pulled (or MVC2) framework, and Struts2's model-view-controller pattern is implemented through the following five core sections:

  • Actions
  • Interceptors
  • Value Stack/OGNL
  • Results (Results)/Results type
  • View technology
Struts2 is slightly different from the traditional MVC framework because it is acting as a model rather than a controller, although there will be some overlap.

Struts2 architecture

The figure above depicts the models, views, and controllers under the Struts2 advanced system architecture. T he controller is implemented by Struts2 assigned servlet filters and interceptors, the model is implemented through Actions, and the view is a combination of result type and result. Value stacks and OGNLs provide common routes, links, and integration with other components.
In addition to the above sections, there is a lot of component-related information. Web application components, Action components, interceptor components, result components, and more.
These are architectural overviews of the Struts2 MVC pattern, and we'll take a look at the sections in a later section.

The request lifecycle

From the description in the image above, we can explain the user's request life cycle in Struts2 according to the following points:
  • The user sends a request for a resource requirement to the server (ex: page).
  • The core controller reviews the request and determines the appropriate action.
  • Configure interceptor features with authentication, file uploads, and more.
  • Perform the selected action to complete the requested action.
  • In addition, the configured interceptor can do any post-processing if needed.
  • Finally, the results are displayed by the view and returned to the user.