Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在处理的一个项目有一个用于休息方法的@RequestMapping 映射,如下所示:
/v{version:[1-9]}
有人可以解释这是在做什么吗,这是否意味着 url 可以在那个地方包含 1-9?
版本是一个变量名,作为 URL 中的路径参数。括号部分是一个正则表达式。在这种情况下,从 1 到 9 范围内的任何一个数字。
因此,URL 的该部分对/v4之类的内容有效,并且您可以将代码中的数字部分作为名为version的变量访问。