读书人

spring3.2 带matrix变量的URL匹配有关

发布时间: 2013-03-21 10:08:17 作者: rapoo

spring3.2 带matrix变量的URL匹配问题

问题描述:

1、url可能是

http://localhost:9080/es-web/login

或一个以;开头的matrix变量

http://localhost:9080/es-web/login;JSESSIONID=a3595636-e414-4cff-bd37-a42edf53193d

?

2、控制器处理方法@RequestMapping匹配pattern写法

spring 3.1前,以下写法是没有问题的

 at org.springframework.util.Assert.state(Assert.java:385)
at org.springframework.util.AntPathMatcher.extractUriTemplateVariables(AntPathMatcher.java:287)
at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleMatch(RequestMappingInfoHandlerMapping.java:102)

??

3、解决方案

我们可以使用正则表达式解决

?

2、修改spring源码,匹配时把『;……』,即分号及后边的去掉(spring3.1就是这么实现的)。

?

综上,在不修改源码的情况下,最简单的就是使用正则表达式模式/{login:login;?.*}

?

?

@MatrixVariable使用请参考

http://jinnianshilongnian.iteye.com/blog/1830409

读书人网 >软件架构设计

热点推荐