requestMapping @PathVariable解析值之后,是否可以获取完整的路径值?
requestMapping @PathVariable
这就是: /{id}/{restOfTheUrl}应该可以解析/1/dir1/dir2/file.html成id=1和restOfTheUrl=/dir1/dir2/file.html
/{id}/{restOfTheUrl}
/1/dir1/dir2/file.html
id=1
restOfTheUrl=/dir1/dir2/file.html
任何想法,将不胜感激。
URL的不匹配部分显示为名为的请求属性HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE:
HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE:
@RequestMapping("/{id}/**") public void foo(@PathVariable("id") int id, HttpServletRequest request) { String restOfTheUrl = (String) request.getAttribute( HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); ... }