First, what is the request resource path
The address format entered in the browser address bar is as follows:
Http://ip:port/appName/xx.html
Where appname/xx.html is the request resource path
Second, the Web server to the request path processing process
Enter http://ip:port/appName/xx.html in the browser address bar
- The browser establishes a connection to the Servlet container based on Ip,port, and then sends the request resource path appname/xx.html past to the container
- The container finds the folder according to the application name "/appname" and the container will default to a servlet, looking for all servlet configuration "" in the Web. xml file to see if there is a matching servlet.
Third, match the servlet rule
1. Exact match
By comparing the specific resource names in the request resource path to the "" in the Web. xml file, the corresponding resource is found and executed after the match is strictly equal
-such as: abc.html
-Although the application has abc.html this specific page, it will execute the url-pattern corresponding servlet instead of returning to the specific abc.html page.
2. Wildcard match
- Use "*" to match 0 or more characters
- such as:/*
- Represents the input any different URL addresses are matched successfully
- Http://ip:port/appName/abc.html Matching Success
- Http://ip:port/appName/abc/def also matches the success
3. Suffix matching
-You cannot start with a slash, use "*." Any number of characters at the beginning
-For example: *.do will match all requests ending with ". Do"
-Http://ip:port/appName/abc.do Matching success
-Http://ip:port/appName/abc/abc.do also matches the success
4. Processing of a servlet without matching
- If exact matches, wildcard matches, and suffix matches do not match successfully, the container looks for the appropriate file
- Find the corresponding file and return
- Returned 404 Not Found
Note: The highest priority is the exact match
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
How the Servlet container handles the request resource path