Struts MVC
Struts is an application framework that allows the construction of dynamic Web applications using the MVC design pattern.
ActionServlet
The ActionServlet receives an HTTP request, invokes the requested actions on the Model and selects the next view to display. It is the core of the framework. One instance of the ActionServlet class receives all incoming requests. The ActionServlet sets the state of an ActionForm using corresponding fields from the HTTP request, optionally asks it to validate itself and passes it to a mapped Action. Requests are mapped to Actions using a configuration file (struts-config.xml).
- The Controller layer is implemented by Servlets.
- The view is implemented using JSPs.
- The Model layer is typically implemented using JavaBeans or Enterprise JavaBeans.
Struts MVC Architecture
Controller Components
Struts' main Controller components consist of a Front Controller servlet, ActionServlet, and the ActionForm and Action classes.ActionServlet
The ActionServlet receives an HTTP request, invokes the requested actions on the Model and selects the next view to display. It is the core of the framework. One instance of the ActionServlet class receives all incoming requests. The ActionServlet sets the state of an ActionForm using corresponding fields from the HTTP request, optionally asks it to validate itself and passes it to a mapped Action. Requests are mapped to Actions using a configuration file (struts-config.xml).
ActionForm
The ActionForm class represents the form data. The ActionServlet instance automatically populates its properties with values from the input form and passes it to the requested Action. The ActionForm is also used to hold dynamic data from the Model to be displayed by the View.
The ActionForm class represents the form data. The ActionServlet instance automatically populates its properties with values from the input form and passes it to the requested Action. The ActionForm is also used to hold dynamic data from the Model to be displayed by the View.
Action
The Action class contains logic to call the Model layer. When executed by the ActionServlet, it invokes Model objects to perform the business logic, and then tells the ActionServlet Controller where to go next.
The Action class contains logic to call the Model layer. When executed by the ActionServlet, it invokes Model objects to perform the business logic, and then tells the ActionServlet Controller where to go next.
Comments
Post a Comment