Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc 将ant样式的路径捕获从spring mvc 3.0更新为3.1_Spring Mvc - Fatal编程技术网

Spring mvc 将ant样式的路径捕获从spring mvc 3.0更新为3.1

Spring mvc 将ant样式的路径捕获从spring mvc 3.0更新为3.1,spring-mvc,Spring Mvc,在spring 3.0.x中,我有一个处理程序方法,它的工作方式非常类似: @RequestMapping("/foo/{version:\\d+}/**") public void handleVersionedResource(@PathVariable("version") Long version, HttpServletRequest request, HttpServletResponse response) { String path = (String) request

在spring 3.0.x中,我有一个处理程序方法,它的工作方式非常类似:

@RequestMapping("/foo/{version:\\d+}/**")
public void handleVersionedResource(@PathVariable("version") Long version, HttpServletRequest request, HttpServletResponse response) {
     String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);

     // rest of the code maps path and version to a real resource and serves 
     // content with extra long cache control / expires headers
 }
在3.0.x中,ff请求url是/foo/12345/some/resource,然后是path=“some/resource”(请求匹配的**部分)

但是,在3.1.x中(同时使用3.1.0.RELEASE和3.1.1.RELEASE进行了尝试),path=与完整的请求路径匹配,因此在我前面的示例中为“/foo/12345/some/resource”

所以问题是,有没有人有最简单的方法来复制我在3.0.x中得到的行为?还有,有没有什么洞察到为什么这种行为发生了变化?我一开始做错了吗

更新: 重复-也没有给出很好的答案。

建议在\u HANDLER\u MAPPING\u属性中的HandlerMapping.PATH\u是Spring的内部属性,不应在应用程序中使用


使用第二个链接中的AntPathMatcher进行类似操作可能是您的最佳选择