Spring-MVC PathVariable匹配正则表达式,不以word开头

had*_*uri 4 java spring spring-mvc request-mapping

我希望将所有请求与一个不以'api'开头的PathVariable匹配.我在RequestMapping之后测试.spring可以匹配请求,但无法获得PathVariable的值.我怎么解决这个问题?

@RequestMapping(value = "/{name:(?!api).+}", method = RequestMethod.GET)
public void getNotApi(@PathVariable String name, HttpServletResponse response) {
    ...
}
Run Code Online (Sandbox Code Playgroud)

我收到一些请求的消息如下localhost:8080/resource.

Error 500 Missing URI template variable 'name' for method parameter of type String

fg7*_*8nc 6

@RequestMapping(value = "/{name:^(?!api).+}", method = RequestMethod.GET)
Run Code Online (Sandbox Code Playgroud)