Struts architecture
Www.5272.com 2002-12-6 5272
Struts architecture
Struts framework architecture
Hu Changcheng (Silver Fox 999)
Keyword
Struts, Framework, Architecture, Componennt, MVC
Preparatory knowledge
Before starting to learn Struts, the following knowledge points need to be understood: Models - View - Control Software Architecture, JSP / Servlet Web Application, J2EE Architecture. If you have aware of the customer tag class (Customer Taglib), it is more likely to understand the Taglib of the Struts itself.
Overview This article mainly explains what Struts Framework, its framework structure, component structure, and simple configuration explanation. For its applications, please refer to "Struts Installation and Application" and "Struts Practical Case Analysis" later. The article includes the following four parts: 1. Framework concept and architecture III, Struts concept and architecture, Struts work principle and component (struts Componennts) Struts configuration file profile (Struts Deployment Description)
First, the Framework concept has always said that struts is a web framework. So let me see what is Framework. (I want to translate Framework with the word "frame", but later found less ideal and complete, so I will use Framework's word) Framework concept is not very new, with the development of software development, more In the software development project of the layer, it is reusable, easy to expand, and is a well-tested software component, which is increasingly favored. This means that people can use sufficient time to analyze, build business logic applications, rather than complicated code projects. So people will abstract the solution to the same type of problem, extract into an application framework. This is what we said. Framework's system provides a set of clear mechanisms to make developers easily extend and control the structure of the entire Framework development. Typically, there is a "command and control" component in the framework of Framework ("Command and Control" Component - Framework Factory and Manager. Image (2): Framework system
Basically, based on the application response (Request-response) mode Framework, there is basically composed of the following performance logical structures. (1) Controller - Controlling the coordination of each component in Framework. (2) Business logic - this is the key to Framework wants to solve the problem. Of course, the FRAMWORK itself is just the concept and several basic components of the sufficient service. The real implementation of the customer's business logic, and the developer needs to expand again on Framework. (3) Data logic - Most application systems require data interaction, which mainly includes data logic and data access interfaces. For data logic, if you understand data modeling (data modeling) may be easily understood. Let's go to our topic - Struts' structure
Second, the concept of Struts and the architecture Struts has a group of collaborative classes (components), Servervet, and JSP TAG LIB. The web application based on the Struts architecture basically meets the design criteria for JSP Model2, which can be said to be a change type of MVC design mode. According to the description of Framework on the top, we are easy to understand why Struts is a web framework, not just a combination of tag libraries. But Struts also contains a wealth of tag libraries and utility classes that are independent of the framework. Struts has its own controller, integrating other technologies to realize the model layer (Model) and view layers. In the model layer, Struts can be easily combined with data access technology, including EJB, JDBC, and Object Relation Bridge. At the view layer, Struts can combine with JSP, Velocity Templates, XSL, and so on.
2.1 Struts' relationship with web app
Since Struts is called Web Framework, then it is definitely based primarily based on Web-layer application system development. According to J2EE Architecture, Struts should be the same as the Web Container like JSP / servlet. As shown in the picture (3) (3): Struts and WebApp relationship
2.2 Struts Architecture We say that struts framework is an embodiment of MVC mode. Here we take a look at the architecture of Struts from models, views, and control. Picture (4) shows the principle of the work of the Struts Framework's architecture to respond to customer requests. Picture (4): Struts Architecture
2.2.1 From the view angle (view) is mainly established by JSP, Struts itself includes a set of scalable custom label libraries (Taglib) that simplifies the process of creating user interfaces. Currently include: Bean Tags, HTML Tags, Logic Tags, Nested Tags, TEMPLIB. For more information on them, please refer to the Struts User Manual 2.2.2 From the Model model mainly represents a state of a system (sometimes, the business logic operation of changing the system status is also divided into the model). In Struts, the status of the system is mainly Actiomform Bean, in general, these states are non-persistent. If you need to convert these states into persistent data storage, the Struts itself also provides a utitle package, which can be easily and database operation 2.2.3 From the controller angle (Controller) in Struts Framework, Controller is mainly an ActionServlet, but for business logic The operation is mainly completed by Action, ActionMapping, ActionForward (maybe these components, should be divided into a business logic in the model). Among them, Action plays an implementation of true business logic, and ActionMapping and ActionForward specify the direction of operation of different business logic or processes.