1.Brief IntroductionStrutsFramework initialization process.
Answer:
For Web applications that adopt the Struts framework, the actionservlet controller is loaded and initialized when the web application starts.
Actionservlet reads configuration information from the struts-config.xml file and stores them in the actionmappings object.
In Struts framework, the controller is mainly actionservlet, but the operations on the business logic are mainly coordinated by the action, actionmapping, and actionforward components (maybe these components, should be divided into the business logic in the model ).
Action acts as the real implementer of the control logic, while actionmapping and actionforward specify the operation direction of different business logic or processes.
2.Brief IntroductionStrutsWorkflow of the Framework responding to customer requests
Answer:
(1) If the actionmapping instance does not exist, create an actionmapping object that contains information about the action to which the request is forwarded.
(2) If the actionform instance does not exist, create an actionform object and save the form data submitted by the customer to the actionform object.
(3) determine whether form verification is required based on the configuration information. If verification is required, call the validate () method of actionform.
(4) If the validate () method of actionform returns NULL or returns an actionerrors object that does not contain actionmessage, the form verification is successful.
(5) The actionservlet determines the action to forward the request to based on the configuration information. If the corresponding action instance does not exist, create the instance first, and then call the action execute method.
(6) The execute method of action returns an actionforward object, and the actionservlet forwards the customer request to the JSP component pointed to by the actionforward object.
(7) The JSP component pointed to by the actionforward object generates a dynamic webpage and returns it to the customer.
For step (4) of the above process, if the validate () method of actionform returns an actionerrors object that contains one or more actionerrors, it indicates that the form verification fails, at this time, the actionservlet will directly forward the request to the JSP component that contains the customer's submission form. In this case, no action object is created and the action's execute method is called.
3 strutsWhat types of data verification can be performed for the framework?
Answer:
Form Verification (processed by actionform bean): If the user does not enter a name in the form, the form is submitted and a form verification error is generated.
Business logic verification (handled by Action): If the name entered by the user in the form is "monster", greetings to "monster" are not allowed according to the business rules of this application, therefore, a business logic error is generated.
4Brief IntroductionForm BeanForm verification process.
Answer:
1. When the user submits an HTML form, the Struts framework automatically assembles the form data into the actionform bean.
2. the Struts framework then calls the validate () method of actionform bean for form verification.
3. If the actionerrors object returned by the validate () method is null or does not contain any actionmessage object, no error is returned, and data verification is successful.
4. If actionerrors contains an actionmessage object, it indicates a verification error has occurred. The Struts framework saves the actionerrors object to the request range and forwards the request to the appropriate view component, the view component displays the error messages contained in the actionerrors object within the request range using the <HTML: errors> label, prompting you to modify the error.
5InStrutsConfiguration FileActionWhat attributes and child elements are contained in the element?
Answer:
Path attribute: Specifies the path of the request to access the action.
Type attribute: Specifies the complete Class Name of the action.
Name attribute: Specifies the actionform bean to be passed to the action.
Scope attribute: Specifies the storage range of the actionform bean.
Validate attribute: Specifies whether to perform form verification.
INPUT attribute: Specify the forwarding path when form verification fails.
The <action> element also contains a <forward> sub-element that defines a request forwarding path.
6.Brief DescriptionActionform BeanFunction
Answer:
1. actionform bean is also a type of JavaBean. In addition to some conventional JavaBean methods, actionform bean also contains some special methods for verifying HTML form data and resetting its attributes as default values.
2. the Struts framework uses actionform bean to transmit form data between the view component and the Controller component.
3. the Struts framework saves the user input form data received by the view component in the actionform bean and passes it to the Controller component, the Controller component can modify the data in the actionform bean. Use the struts tag to read the information of the modified actionform bean and reset the HTML form.
7.DescriptionActionformProcedure
Answer:
(1) Check the action ing and make sure that the actionform ing has been configured in the action.
(2) query the configuration information of form bean Based on the name attribute.
(3) Check the use range of formbean of action to determine whether the form bean instance already exists under this range.
(4) If an instance of this form bean already exists in the current range, but is of the same type for the current request, it will be reused.
(5) Otherwise, create a new form bean instance.
(6) form bean reset () method standby call
(7) Call the corresponding setter method and assign values to the status attribute.
(8) If the validatede attribute is set to true, The Validate () method of form bean is called.
(9) If no error is returned for the validate () method, the controller uses actionform as a parameter and passes it to the execute () method of the Action instance for execution.
8.Which of the following labels are used?StrutsTag
A. <HTML: Form>
B. <HTML: Text>
C. <HTML: errors>
D. <HTML: Message>
Answer: A B C
9,FormbeanFunction
A: formbean is a type of JavaBean. In addition to the conventional method with JavaBean, it also contains some special methods for verifying form data and resetting its attributes to the default value. Formbean is used to transmit form data between the view component and the Controller component. The view component receives the form data entered by the user, saves it in formbean, and passes it to the Controller component. The Controller component can modify the data in formbean.
10,ForwardAndGlobal-forwardDifference
A: Forward finds the corresponding JSP page based on the value of action return. When multiple actions return the same value together, you can write this forward element in global-forward.
11.Problem:StrutsComponents contained in the application view?
Option:
(A) JSP
(B) Servlet
(C) actionservlet
(D) Action
(E) JavaBean representing the business logic or business data
(F) EJB
(G) custom tags
Answer: A, G
12Problem:StrutsComponents contained in the application Controller?
Option:
(A) JSP
(B) Servlet
(C) actionservlet
(D) Action
(E) JavaBean representing the business logic or business data
(F) EJB
(G) custom tags
Answer: B, c, d
13.InStrutsConfiguration FileActionWhat attributes and child elements are contained in the element?
Answer:
Path attribute: Specifies the path of the request to access the action.
Type attribute: Specifies the complete Class Name of the action.
Name attribute: Specifies the actionform bean to be passed to the action.
Scope attribute: Specifies the storage range of the actionform bean.
Validate attribute: Specifies whether to perform form verification.
INPUT attribute: Specify the forwarding path when form verification fails.
The <action> element also contains a <forward> sub-element that defines a request forwarding path.
14.Problem:StrutsComponents contained in the application model?
Option:
(A) JSP
(B) Servlet
(C) actionservlet
(D) Action
(E) JavaBean representing the business logic or business data
(F) EJB
(G) custom tags
Answer: F
15.Problem:StrutsIn the FrameworkFormbeanWhich of the following statements are true:
A formbean is a data Bean mainly used to encapsulate the data submitted by the form and pass the data to the action.
In formbean, B can verify the format of parameters passed by PAGE upload. This verification is a client-side verification.
Every time a C user submits a form, a new formbean instance is generated.
D. The dynamic formbean cannot be verified.
Answer:
16. Problem:StrutsInActionIn the configuration information,NameAttribute refers:
A: name of the current action instance
B. Name of the class where the current action is located
C. Name of the formbean instance called in this action
D. Package name of the formbean class called in this action
Answer: c
17. Problem:AboutStrutsClasses andMVCWhich of the following statements is false?
A JSP file to implement the view Function
B actionservlet this class is the controller of the entire struts Project
C actionform and action both belong to the model section.
D. A struts project can have only one Servlet
Answer: d
18Q: Which of the following statements are true?
Option: (a) each HTTP request corresponds to a separate actionservlet instance.
(B) For each HTTP request to access helloaction, the Struts framework creates a separate helloaction instance.
(C) Each sub-application corresponds to a separate requestprocessor instance.
(D) Each sub-application corresponds to a separate web. xml file.
Answer: c
19 actionform BeanWho created the object?
Option:
(A) <HTML: Form> tag processing class
(B) actionservlet
(C) requestprocessor
(D) Action
Answer: c
20,StrutsFramework, which is wrong?
A. Unable to complete the upload function in struts
B. Struts framework based on MVC Mode
The C Struts framework is prone to complicated procedures and unclear structures.
D struts can effectively reduce the number of class files of the project
Answer: c
21, Problem:BelowCodeDefines a variable and how to output its value.?
<Bean: Define id = "stringbean" value = "helloworld"/>
Option: (a) <Bean: write name = "stringbean"/>
(B) <Bean: write name = "helloworld"/>
(C) <% = stringbean %>
(D) <% string mybean = (string) pagecontext. getattribute ("stringbean", pagecontext. page_scope); %> <% = mybean %>
Answer: A, D
22, Problem:Put static text inResource bundleInsteadJSPWhat are the advantages of static text contained in files??Answer: Improves maintainability, improves reusability, and supports internationalization.
23InStrutsConfiguration FileActionWhat attributes and child elements are contained in the element?
Answer:
Path attribute: Specifies the path of the request to access the action.
Type attribute: Specifies the complete Class Name of the action.
Name attribute: Specifies the actionform bean to be passed to the action.
Scope attribute: Specifies the storage range of the actionform bean.
Validate attribute: Specifies whether to perform form verification.
INPUT attribute: Specify the forwarding path when form verification fails.
The <action> element also contains a <forward> sub-element that defines a request forwarding path.
24. Problem:AboutStrutsClasses andMVCWhich of the following statements is false?
A JSP file to implement the view Function
B actionservlet this class is the controller of the entire struts Project
C actionform and action both belong to the model section.
D. A struts project can have only one Servlet
Answer: d