Springboot 中的 GetMapping 排除路径变量中的 html 个文件

GetMapping in Springboot exclude html files in pathvariable

我有一个带有以下 GetMapping 的控制器

@GetMapping(value = "/{path}") 
     public ResponseEntity searchAPI(@PathVariable("path") String API_NAME)

但我必须从这个 GetMapping

中排除 /index.html

我这样试过

@GetMapping(value = "/{path:^.*(?!index.html)}") 

但这不起作用 我需要单独写每个 API 吗? 请帮助我

点(.)是一个特殊字符,可以匹配任何符号,需要用反斜杠转义:

@GetMapping(value = "/{path:^(?!index\.html).*}")