如何将我的最后一个路径变量作为剩余路径?我有类似的东西,但它没有被击中:
@RequestMapping(value = "{storageId}/{repositoryId}/{path}/**",
method = RequestMethod.PUT)
@RequestMapping(value = "{storageId}/{repositoryId}/{path}/**", method = RequestMethod.PUT)
public ResponseEntity upload(@PathVariable(name = "storageId") String storageId,
@PathVariable(name = "repositoryId") String repositoryId,
@PathVariable(name = "path") String path,
MultipartFile multipartFile)
throws ...
{
...
}
在泽西岛,我可以轻松地做到这一点:
@Path("{storageId}/{repositoryId}/{path:.*}")
...但我必须将一些代码迁移到Spring MVC。
问题是如果我的网址是:
http://localhost:48080/storages/storage0/snapshots/org/foo/bar/metadata/metadata-foo/3.1-SNAPSHOT/metadata-foo-3.1-20161017.182007-1.jar
我的path
被截断为:
metadata/metadata-foo/3.1-SNAPSHOT/metadata-foo-3.1-20161017.182007-1.jar
这显然不正确,因为它应该是:
org/foo/bar/metadata/metadata-foo/3.1-SNAPSHOT/metadata-foo-3.1-20161017.182007-1.jar
欢迎任何建议!
答案 0 :(得分:0)
@RequestMapping(value = "{storageId}/{repositoryId}/{path}/**",
method = RequestMethod.PUT)
public ResponseEntity upload(@PathVariable(name = "storageId") String storageId,
@PathVariable(name = "repositoryId") String repositoryId,MultipartFile multipartFile,HttpServletRequest request)
throws ...
{
String restOfTheUrl = (String) request.getAttribute(
HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
}