This annotation works exactly the same as @RequestMapping in Spring. Here are the annotations in Spring:
Click @path of the exercise code in Eclipse:
Find that the value of this path also supports regular expressions:
So I used a regular expression like this:
Test success:
Use this test fails, this is my expectations: http://localhost:9498//hello/3 also found from the output of the Eclipse framework parses the @ the entrance code of Path, kill two birds with one stone. After the entry method sets the breakpoint,
Then you can debug:
How is a regular expression evaluated
The regular expressions we specify in our application code will have to be used by the framework somewhere, so we can already set breakpoint debug: This is how we apply the specified regular expressions:
Here’s the path I’m testing passed :/3. Obviously the match() method of the regular expression instance returns false,
So finally, 404 error,
For more of Jerry’s original articles, please follow the public account “Wang Zixi “: