In this chapter we will discuss about the Architecture and Lifecycle of Struts 2. This Struts 2 Architecture is based on WebWork and XWork framework. Struts 2 promotes the MVC framework and is tightly coupled framework. After reading this tutorial you will be able to understand the Architecture of Struts 2 framework.
Struts 2 framework is based on the concepts of MVC framework. The MVC design patterns divides the applications into three kinds of components namely Model, View and Controller. These components have specific roles and responsibilities.
Struts 2 framework is Open source popular MVC framework for writing the web based applications. It consist of Controller, Model and View components. Here are the description of each components of Struts 2 framework.
Controller receives User input and validate it. Controller is responsible to perform the business operation that modifies the state of the data model. Controller has the ability to send the command to change View presentation of the model. It can also send command to update the Model state.
Model handles the data of the application and responds to the request from View and instructions from Controller. It then update itself accordingly and informs about the change in its state to associated Views and Controllers. Views than updates its output and Controllers change the available set of commands accordingly.
View ask for information from Model via Controller that it requires to generate output for user. View is responsible for generating the UI interface for the application. It generates the view based on the model data.
Fig. MVC Application
Lifecycle of Struts 2:
Request processing lifecycle of Struts2 framework:
Posted on: September 21, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles