One, what is the framework?
The framework is to provide a unified set of interfaces and programmable reusable components, while we can expand our own specific logic within the framework.
Second, MVC design pattern
The application is divided into 3 parts: Model models, view views, controller Controller model components: responsible for business logic; The model contains the core functionality of the application. The model encapsulates the state of the application. Sometimes the only feature it contains is the state. It knows nothing about the view or the controller. View component: A view that is responsible for representing the business scope, and the view provides the representation of the model. It is the appearance of the application. A view can access the model's Read method, but it cannot access the Write method. In addition, it knows nothing about the controller. When you change the model, the view should be notified. Controller component: Responsible for controlling the flow and state of user input, and the controller responding to user input. It creates and sets the model. Struts, which is an MVC implementation using servlet and JavaServer Pages technology, a project of Struts,apache organization, an open source implementation of MVC;
Three, what is the Struts framework
Struts is a reusable MVC 2 design that consists of a set of mutually collaborative classes, servlet, and JSP tags. This definition indicates that struts is a framework, not a library, but the Struts framework also contains rich tag libraries and utility classes that work independently of the framework.
Iv. Overview of Struts
1,client Browser (Customer browser) creates an event for each HTTP request from the client's browser. The Web container responds with an HTTP response.
The 2,controller (Controller) controller receives requests from the browser and decides where to send the request. In the case of Struts, the controller is a command design pattern implemented in a servlet. Struts-config.xml file Configuration Controller command.
3, the business logic business logic updates the state of the model and helps control the flow of the application. In the case of struts, this is done by the action class as the "thin" wrapper for the actual business logic.
The state model of the 4,model (model) represents the state of the application. The business object updates the state of the application. Actionformbean represents the state of the model at the session level or at the request level, rather than at the persistence level. JSP files use JSP tags to read information from Actionformbean.
The 5,view (view) view is a JSP file. There is no process logic, no business logic, no model information-only tags. Marking is one of the factors that make struts different from other frameworks, such as Velocity.
Five, controller (Controller) in struts
Implementation of the command design pattern: The Struts controller maps events (usually HTTP post) to a servlet of the class.
Actionservlet (Command) creates and uses Action, Actionform, and Actionforward. Configure the Command with the Struts-config.xml file to extend the Action and actionform to solve specific problems. You can add Command functionality by extending Actionservlet.
The controller components in the Struts framework consist of three parts:
1, the Message control module; All of the user's submission requests are sent to the Message control module, where the message processing module is found by the message bus module according to the View mapping module to perform the processing logic. The Message control module receives requests from all users and finds processing based on the request view. The strtus is accomplished through the Actionservlet and Requestprocessor classes.
2, the message processing module; The module performs the logical processing of the message, so it is typically implemented by the user extension. Struts is implemented by the action class.
3, view mapping module, the combination of controller logic and view logic is to establish its link through configuration module and configuration file. The configuration module in struts is done through the Moduleconfig class, and the configuration file is provided by the Struts-config.xml file.