What is MVC in struts 2 ?

 MVC in struts 2 :

In struts Model, View and Controller(MVC) is a design pattern, which is used to develop web application in java.
Model : It is responsible for retrieving data from the database and saving the data into the database. It also responsible to implements all business logic. When a data entered by the user through view are checked in the model before saving into the database. Data access, data validation and the data saving logic are part of model component.

View: It is represents the user view of the application which is responsible for taking the input from the user, dispatching the request to the controller and then receiving response from the controller and displaying the result back to the user. html, jsp, custom tag libraries, resources files are the part of view component.

Controller: It is intermediary between Model and View components. It is also responsible for receiving the request from client through view. Once request is received from client it executes the appropriate business logic from the Model and then produce the result to the user using the View component. ActionServlet, Action, ActionSupport and struts.xml are the part of Controller.

You can better understand through below diagram :

mvc diagram

 

Advertisements