A detailed experience of struts working principle

Source: Internet
Author: User

One.

Once the server receives the URL request, it first runs the filter in Web. XML to see what requests can be accepted.

<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>

Like * This means that any request that is a URL input can be accepted to run, and if it is *.action, only the request with the suffix action will be processed.

Then go to the struts.xml to match if there is any configuration of this action, and if so, execute it. For example, if our request path is localhost:8080/a/b/register.action, then we will go to struts.xml see if there is no action under this path, if not, then look localhost:8080/a/ Register.action inside there is no, know not to find so far. This involves namespace issues.

The corresponding action is found and the corresponding request is processed

Two.

If there is a problem related to form submission, we usually first get the form submission page (not filter the request), if we deploy the project, we can naturally access it, and then click "Submit" when the action of the form form will be processed to see if the request satisfies the requirements of the filter, And then proceed to the "one" step

This time the URL will be accessed by the path to the URL of the filter in Web. XML to achieve a jump.

A detailed experience of struts working principle

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.