首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

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

2013-03-21 
spring3.2 带matrix变量的URL匹配问题问题描述:1、url可能是http://localhost:9080/es-web/login或一个以

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

热点排行