Struts2 personal understanding

Source: Internet
Author: User

Struts2 personal understanding
I. Working principle the processing in the Struts2 framework is roughly divided into the following steps: 1. The client initializes a request pointing to the Servlet container (such as Tomcat). 2. The request goes through a series of filters) (These filters have an optional filter called ActionContextCleanUp, which is very helpful for the integration of Struts2 and other frameworks, such as SiteMesh Plugin.) 3 then FilterDispatcher is called, filterDispatcher asks ActionMapper to determine whether to call an Action. 4. If ActionMapper decides to call an Action, FilterDispatcher submits the request processing to ActionProxy 5. ActionProxy asks the framework Configuration file through Configuration Manager, locate the Action class 6 ActionProxy to be called and create a Actio NInvocation instance. 7. The ActionInvocation instance uses the naming mode for calling. Before and after the Action is called, the call of the relevant Interceptor (Intercepter) is involved. 8. Once the Action is executed, ActionInvocation is responsible for finding the corresponding return result based on the configuration in struts. xml. The returned result is usually a JSP or FreeMarker template to be represented (but not always, or another Action chain. You can use the tag inherited from the Struts2 framework in the Process of representation. This process involves ActionMapper 2 workflow 1. The client browser sends an HTTP request. 2. According to the web. xml configuration, the request is received by FilterDispatcher 3. According to struts. xml configuration, find the Action class and method to be called, and inject the value to Aciton4 in IoC mode. Action calls the business logic component to process the business logic. This step contains form verification. 5. The Action is executed according to struts. in xml, locate the corresponding returned result and jump to the corresponding page. 6. Return the HTTP Response to the client browser and view the summary of Struts2's principles. I will also summarize the results for subsequent interviews, the following is my question 1. The customer server initiates a request pointing to the Tomcat container through the HTTP protocol. What does tomcat do when it receives the request? 2. Our web. xml configuration <filter> <filter-name> struts2 </filter-name> <filter-class> org. apache. struts2.dispatcher. ng. filter. strutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name> struts2 </filter-name> <url-pattern>/* </url-pattern> </filter-mapping> The org. apache. struts2.dispatcher. ng. filter. strutsPrepareAndExecuteFilter, what is the use of this Filter class? This/* is to intercept all requests. What does it do when it intercept the requests? <Url-pattern>/* </url-pattern> 3. we struts. xml configuration <struts> <package name = "default" namespace = "/" extends = "struts-default"> <action name = "hello"> <result>/Hello. jsp </result> </action> </package> </struts> who is responsible. for xml configuration, find the Action classes and methods to be called? 4. Finally, according to struts. the configuration in xml finds the corresponding returned result. In the end of returning an HTTP Response to the client browser, I think it is clear about the Struts principle. It is not only about the writing principle of the data, we also need to summarize these issues.

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.