Wildcard characters in the servlet mapping path

Source: Internet
Author: User
Tags tomcat
Wildcard characters in the map path

Sometimes, you want all paths under a directory to have access to the same servlet
At this point, you can use the wildcard character in the path of the servlet map *

Wildcard formats are available in two formats *. extension

Like what
*.do, matches all URL address formats with. Do ending AS/*

Like what
/abc/*, match all URL addresses starting with/abc Note

The format of these two wildcard characters, cannot be mixed with
Like what
/abc/*.do, as an illegal virtual path

When a client accesses a servlet, it can match multiple virtual paths if the requested URL address
Tomcat will take the most specific matching principle to see the virtual path closest to the request URL
Like what
Mapping relationships
/abc/*--Mapping to Servlet1
/*--Mapping to Servlet2
/abc--Mapping to Servlet3
*.do--Mapping to Servlet4

Request URL
When the URL is:/abc/a.html
/abc/, or/, can match this URL
Tomcat will call Servlet01

When the URL is:/ABC
/abc/*, or/ABC, can match this URL.
Tomcat will call Servlet03

When the URL is:/a.do
/, or. Do, can match this URL
Tomcat will call Servlet2

When the URL is:/xxx/yyy/a.do
. Do, or/, can match this URL
Tomcat will call Servlet2

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.