Escolar Documentos
Profissional Documentos
Cultura Documentos
Controller
(Servlets)
View Model
Model – Contains the business logic and interact with persistent logic to store, retrieve and manipulate the data
into the database.
View – Responsible for displaying the results back to the user. Typically view layer is developed using the UI
technologies such as JSPs, Faces and Velocity etc…
Controller – Acts as mediator between Model and View and handles all the requests from user and selects
appropriate view to return.
Struts Architecture
Framework, designed based on the MVC design pattern. It comes with couple of components listed below
o ActionServlet – Acts as controller in MVC pattern and follows a Front Controller design paatern.
o Java classes – Class library to develop Action classes, Form beans, and etc…
o Tag library – Tag library to develop the views (JSPs) to implement the UI components
o Validation framework – In build validation framework to perform the common and business validation.
Forward
View
Response (JSP)
Struts flow
o When user makes a request through browser, the request will comes to the ActionServlet configured in the
web.xml
o ActionServlet was already instantiated and loaded the struts-config.xml file where you configured the action
mappings and action forwards.
o Populates the ActionForm with all the request values.
o struts-config.xml file decides which action class to be executed and validates the data entered by the user.
o Action class interacts with Java beans to manipulate the data into the database (Action class -> business layer ->
persistent layer -> database).
o struts-config.xml file will find out the view (jsp page) to where the request should be forwarded.
o Appropriate JSP page will be sent back to the browser as a response that contains the model information to be
displayed to the user.
Note: The beauty about the DynaActionForm is you can create the DTO in one single statement like below.
YourDTO obj = new YourDTO();
BeanUtils.copyProperties(obj, dynaActionForm);
Validation Framework
Struts provide the plug-in to perform the validation on your application includes both business and data related
validation. Below 2 files are the validation framework configuration files.
o validator-rules.xml - Define the rules to be applied.
o Validation.xml – Apply the rules defined in the validator-rules.xml