Use of url-pattern in JavaWeb Servlet, javaweburl-pattern

Source: Internet
Author: User

Use of url-pattern in JavaWeb Servlet, javaweburl-pattern

Use of url-pattern in Java Web Servlet

1. Description of Sevlet and Filter url-pattern

A page request matches only one best Servlet according to url-pattern, and generates a FilterChain based on one or more filters that meet the requirements according to the filter-mapping tag sequence of web. xml.

2. url-pattern Configuration

Configure the web. xml file to define the meaning of the ing:

(1). "/" --> path ing
(2). "*. do" prefix --> extended ing
(3). "/" --> default servlet ing.
(4). Detailed Definition
<Url-pattern>/*. do </url-pattern> Invalid <url-pattern>/*. do in servlet mapping Error
Because "/" matches the path ing and the extended ing, the container cannot judge.

3. url-pattern matching rules

(1). Exact Path Matching
Where the exact matching requirements are met, precision is the main factor;

(2). Longest Path Matching
For example, the url-pattern of servletA is/test /*,
The url-pattern of servletB is/test//*,
Http: // localhost/test/a --> servletB

(3). Extended matching
The container selects the appropriate servlet Based on the extension.

If you have any questions, please leave a message or go to the community on this site for discussion. Thank you for reading this article. Thank you for your support!

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.