Struts study notes (2)

xiaoxiao2021-03-06  67

Then come yesterday :)

It is primarily targeted the Struts's MVC structure, and the general composition of MODEL-View-Control is mainly understood, and struts control flow is understood. Mainly for the study of Control-ActionServlet. Reference http://struts.apache.org/userguide/introduction.html

First, View (view)

Composed of The View: JSP Pages and Presentation Components, including JSTL and custom labels, no longer educational.

Second, MODEL (model)

System State and Business Logic JavaBeans, internal information processing (such as session, etc.), external transaction models, such as enterprise logic, etc. To achieve the purpose, according to my understanding, it should be central to the Web Application (State), and via the call to Business JavaBeans, change, update, update, logic and display separation, View already separated from Business Javabeans as much as possible, resulting in decomposition, modularity of complex systems.

Third, Control Flow (Composition and Control Process of Cotroller)

This is the problem that is primarily understood today.

In Struts, Control Layer includes Controller, as well as developer-defined request handlers, and Several Supporting Objects.

In Struts, the preferred Controller component is an ActionServlet Class, followed by AcitonMapping Class.

According to my understanding, the Controller design in Struts is mainly to avoid interaction between the View layer and the logic layer, reduce the large system coupling degree, which is conducive to the system's expansion. Because in traditional JSP web design model2, the display layer directs the logical transaction to handle Class (or even two together), the system is entangled, resulting in poor design, not intended to expand.

The control layer gets the client (usually the browser) Request, determines which logic Class of this request is handed over to which logic Class is handed over from the Struts, which is determined to display which view compontent is displayed.

Let's see Struts Control Flow

Control layer specific includes Controller Servlet, ActionMappings, ActionFormBeans, etc.

TIP1: ActionMapping, save the request orientation information, guide the Controller to send the correct request to correct Object (FormBeans or directly to Bussiness Tier)

An individual ActionMapping [org.apache.struts.action.ActionMapping] will usually contain a number of properties including: a request path (or "URI"), the object type (Action subclass) to act upon the request, and other properties as Needed.

TIP2: ACIONFORMBeans, according to Contoller's dispatch, handle the form entered by the Client, and then have the Controller Control Send to the developed logic class, and then send back ActionFormBeans, then processed to the developed View page. The effect of it is to verify the integrity and correctness of the information, and the process process is as follows:

Here Is The Sequence of Events That Occur When a Request Calls for an maping That Uses an Actionform:

The controller servlet either retrieves or creates the ActionForm bean instance. The controller servlet passes the bean to the Action object. If the request is being used to submit an input page, the Action object can examine the data. If necessary, the data can be sent back to the input form along with a list of messages to display on the page. Otherwise the data can be passed along to the business tier. If the request is being used to create an input page, the Action object can populate the bean with Any Data That The Input Page Might NEED.

Of course, there are some simple Application, and Controller may give Request to transaction Class, so that the above steps are eliminated, HOWEVER, IN MOST CASES, An Action Object Should Invoke Another Object, Usually a Javabean, To Perform The Actual Business logic.

For the processing flow of the transaction layer, rough

A business-logic bean will connect to and query the database, The business-logic bean returns the result to the Action, The Action stores the result in a form bean in the request, The JavaServer Page displays the result in a HTML form. Of Therefore, the action of ActionFormBeans can be seen.

Third, this part is the key to Struts. It is also a difficult point of thinking. I summarize and understand, I definitely have a mistake, if I find it, please point out, thank you!

转载请注明原文地址:https://www.9cbs.com/read-117982.html

New Post(0)