2004-11-9 Tuesday
1. What is Struts? A: 1) Struts is an open source framework for building a MVC architecture web application; 2) Struts is part of the Jakarta project, sponsored by the Apache Software Fund; 3) By using struts, you can It is clearly separated from the performance layer and the business logic layer; 4) Struts also improves development efficiency by providing a wide JSP tag library. Label library parsing and verify user input, error handling, and international support. 5) We will show you how to build Struts web applications using the Struts development tool.
2. Struts Resources A: In order to learn more about the Struts framework, please pay attention to the Struts official website and the user guide:. Http://jakarta.apache.org/struts. Http://jakarta.apache.org/struts/userguide /introduction.html
3. MVC-View-Controller Architecture Model: 1) MVC architecture mode proposes the developer of the SMALLTALK-80 graphical user interface in 1980; 2) It is controlled from this object-oriented user interface and application control The toolkit is widely used, such as Struts, and improved to meet specific platform requirements, such as J2EE. 3) According to the MVC mode, a software component (an application, one module, etc.) should separate its business logic and its performance layer; 4. MVC Reason: 1) For the same model you have more than one view; 2 ) If commercial logic and its performance layer are built in one, adding additional View will result in considerable interrupts and increasing the complexity of the component; 3) A good example of a Model has a good example of a bank application, it You can change the view by the Internet and mobile phone access; 4) When you change View, you don't want to change the model; 5) View Depends on Model, which is displayed to the user's model's specific aspects; 6) Build View and Model on one, each time When you make a small change to the view, you have to change Model;
5. MVC mode A: This separation can be achieved by dividing components into the following layers:. Model layer, implement business logic;. View layer, implement a user interface for a specific client type; with these two layers, we can realize Business logic and present it to the user. But this only solves half of the problem, we should also interact with Model. This interaction is known as the control layer.
6. Dependency between MVC Answer: | ˉˉˉˉˉ | | control | | __________ | ╲ ╲ ╱ ╲ ↙ | ˉˉˉˉˉ | | | ˉˉˉˉˉ | | | -----> | model | | ___________ | | __________ |
7. MVC Framework and Struts Answer: Struts provides the following components to develop applications using MVC:. Model: Struts does not provide Model class. This business logic must be provided by the developer of the web application in the form of JavaBean or EJB;. View: Struts provides an Action Form to create a Form Bean for transferring data between Controller and VIEW; in addition, Struts provides custom JSP tags The library, the auxiliary developer uses JSP to create an interactive form-based application; the application resource file retains some text constants and error messages, which can be converted into other languages, which can be used in JSP. . Controller: Struts provides an action server that receives the JSP input field to form an action form, and then call an action class. The Action Class provides the logical interface of Model.
8. Components in the Struts web application Answer: 1) a servlet, inherit from org.apache.struts.Action.ActionServlet; mainly implementing a mapping function: map a request URI to an action class; in calling action Before Class, it receives the JSP input field and forms form bean; if specified, the action servlet also requests the form bean to verify the data; it then calls the action class to complete the request. If Form bean is failed, the control is then returned. Give JSP so that the user can correct the data; Action servlet is configured by an XML configuration file. This XML configuration file specifies the relationship between components and their relationships. 2) Multiple JSP pages, provide interfaces to end users; Struts provides a wide range of label libraries to develop easy JSP to develop; JSP shows how Action is ready for information and for users to request new information; 3) Multiple Action Class, inherited from org.apache.struts.Action.Action;. MODEL interface;. When an action is executed, it returns an action forwarding object. This object determines if the user interface displays a response. The Action Class prepares a must-have to display the response, usually as an FORM BEAN, and then use it to the JSP page. The FORM bean used to transmit messages to the action is also used to transmit responses. However, the existence of VIEW Beans that demonstrates data is also common. An Action Forward includes its name, address (URL), and a tag. This tag specifies whether a Forward or Redirect call should be performed. An Action Forward's address usually creates an Action Servlet configuration file, but can also be dynamically generated by the Action itself. 4) Multiple Action Forms inherit from Org.Apache.Struts.Action.Actionform. Action Form is a general JavaBean with a set and get method; usually there is a Form Bean in each web page, but you can also use the coarse grain size Form bean to keep input between multiple web pages. If data verification is required until the Form Bean successfully completes the verification, it will pass to the action. Therefore, the Form Bean can be used as a firewall in JSP and Action, which only allows effective data to enter the system. 5) Each language is an application resource file that contains some application text constants and error messages, which makes internationalization easy.