Struts1.2 source code analysis record

Source: Internet
Author: User

Struts ideas:
1. actionform, dispatchaction, and actionmapping used by struts
2. Main concerns: form, action, and forward
3. how to send request parameters and intercept parameters in the background. do request, how to assemble parameters into form, how to operate form in action, how to find the target page, how to return form to the page, how to read form attributes through tags on the page

Framework main process:
All struts requests must follow the public actionforward execute (actionmapping mapping, actionform form, httpservletrequest request, httpservletresponse res) method of the dispatchaction class.
You can reload the execute method (to complete user verification and database connection initialization), and switch the operation to the processing method based on the method parameter.

framework details:
1. receive. do request
2. convert the parameter to actionform
3. find the corresponding dispatchaction and pass the actionform to the corresponding method of the dispatchaction
4. locate the target page from mapping, serialize the actionform, and send it to the page
5. the page parses the form using tags.
framework code details (processing HTTP requests and returning them):
1. actionmapping mapping = processmapping (request, response, PATH);
2. actionform form = processactionform (request, response, Mapping);
3. processpopulate (request, response, form, Mapping);
4. actionforward forward = processactionperform (request, response, action, form, Mapping);
5. processforwardconfig (request, response, forward);
6. response. sendredirect (response. encoderedirecturl (URI);
7. requestdispatcher RD = getservletcontext (). getrequestdispatcher (URI); Rd. forward (request, response);


Start with the configuration file and resolution configuration file
1. Structure of struts-config.xml
A. Main elements: Data-sources, form-beans, action-mappings, global-forwards, global-exceptions, message-resources, and plug-in
B. Use the common-digester toolkit and DTD for automatic XML parsing and Loading
2. parsing the process of struts-config.xml
A. moduleconfig is a Java object paired with the struts-config.xml
B. After the xml configuration information is loaded into the memory, the resource is allocated to each required module and initialized.


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.