Last night, I read the Xia Xin written <<webwork2_guide>>, although the document is concise, but still a good WEBWORK2 books, see the author's experience and ability are very sophisticated, in this to the author's open source Spirit salute, And in this quote Xia Xin that sentence so many open source projects, Why not open your Documents?
Today, download the latest version of the WEBWORK2, began the source analysis, this document can only be my personal notes, there is no time to carefully proofread, and limited personal ability, it is inevitable that there are a lot of analysis errors or clerical mistakes, and I hope you correct me.
webwork1.x version is a tightly coupled architecture, similar to struts, and webwork2.x version after the adoption of a new architecture webwork2.x+xwork1.x is because he adopted such a framework so that I go to see his source! The new architecture separated the Servlet API with the tight coupling, so that our system structure will be more clear, and system testing and system transplant in the future more convenient, in fact, webwork1.x version I have not seen, the so-called tight coupling is to see the internet is so said, no say ah, hehe!
The role of webwork2.x in the new architecture is to detach the user's HTTP request, make the request completely detached from the servlet API, and then pass the request in map to the xwork1.x, and xwork1.x the map through interceptor The data in is passed to our VO and then called by the corresponding custom action.
The next step is to see how webwork2.x separates HTTP requests, but in fact he achieves them through servletdispatcher. The code looks like this:
Helpers to get access to request/session/application scope
This is used to store request session requests in HTTP
Extracontext.put ("Request", Requestmap);
Extracontext.put ("session", Sessionmap);
Extracontext.put ("Application", Applicationmap);
Extracontext.put ("Parameters", Parametermap);
AttributeMap attrmap = new AttributeMap (extracontext);
Extracontext.put ("attr", Attrmap);
return extracontext;
}
The above is the method in Servletdispatcher Createcontextmap is used to encapsulate HTTP requests to the map, and Servletdispatcher is also the webwork2.x controller, which is responsible for separating the action. He is using the service method to invoke the Serviceaction method, and then by Serviceaction to complete the operation, the code is as follows:
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