Basic flow of Struts

前端 未结 3 1145
情话喂你
情话喂你 2021-01-30 11:45

Well I want to study Struts so I am going to begin with Struts 1, I would like to know the general flow. What files are required?

Whats the function of struts-config.xml

3条回答
  •  深忆病人
    2021-01-30 12:29

    1. When a user submitted a jsp page. that page having (attribute of )action="login.do". the container will call to web.xml. in that web.xml there are two sections servlet And servlet mapping
    2. In servlet mapping it find *.do in the url-pattern. if it found to take the name of servlet. and check the corresponding class. in the servlet section. that class is ActionServlet.
    3. ActionServlet is the controller of Struts module architecture. in Action servlet having the service method. in that method we create RequestPrecessor class instance
    4. Service(req,res) RequestPrecessor rp = new RequestPrecessor();
    5. We call a process method of RequestProcessor class through the instance rp.process(req,res)
    6. In the request processor class have the process method with the parameter of req,res. then it has 1 if condition in this class. that condition return always true. because that is dummy method.

    Inside that condition there are 6 steps are processing

    1. Create a action mapping instance in the Struts- Config.xml. it will keep all details of the action mapping path, value, type forward, validation=true/false, input ="*.jsp" etc these r created instance
    2. Then it will create Form class instance before it check the name of action mapping and form name are coincidence or not if it same it will create form instance
    3. Then it will go to ActionMapping instance the ris mention or not the validate =true/false if false it will not execute the this step else it will execute this step.
    4. Then it will create action instance
    5. Next it will take four parameters of execute Method it will return ActionErrors instance. if it is not empty. it will go to error page other wise it will got to corresponding page. else if it is empty if will go further and display corresponding value of page in jsp view.This is struts flow.

提交回复
热议问题