我正在尝试将此 Google App Engine maven 服务器存储库重写为 Spring。
我的 URL 映射有问题。Maven repo 服务器标准如下所示:
以斜线结尾的 URL,指向一个文件夹,例如:
http://127.0.0.1/testDir/ http://127.0.0.1/testDir/testDir2/
所有其他(末尾没有斜线)指向文件,例如:
http://127.0.0.1/testFile.jar http://127.0.0.1/testFile.jar.sha1 http://127.0.0.1/testDir/testFile2.pom http://127.0.0.1/testDir/testFile2.pom.md5
使用@javax.ws.rs.Path
了与 Spring 不同的支持正则表达式的注释。
我尝试了一堆组合,例如这样的:
@ResponseBody
@GetMapping("/{file: .*}")
public String test1(@PathVariable String file) {
return "test1 " + file;
}
@ResponseBody
@GetMapping("{dir: .*[/]{1}$}")
public String test2(@PathVariable String dir) {
return "test2 " + dir;
}
但我无法弄清楚如何在 Spring 应用程序中以正确的方式做到这一点。
我想避免编写自定义 servlet 调度程序。