spring mvc @PathVariable / 带斜杠方式获取

来源:互联网 发布:js下一个兄弟节点 编辑:程序博客网 时间:2024/06/11 15:16

一、遇上这个问题,百度google了一下,抄袭里面的内容,可以实现,在此备忘


@RequestMapping(value = "/download/{value1}/**", method = RequestMethod.GET)public void getValue(@PathVariable String value1, HttpServletRequest request) throws CommonException {String value = extractPathFromPattern(request);}private String extractPathFromPattern(final HttpServletRequest request) {String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);}


0 0
原创粉丝点击