Spring 3.0中的区分大小写的URL映射

时间:2010-09-17 08:56:10

标签: spring-mvc

看起来,Spring 3.0中基于默认注释的处理程序映射会对不区分大小写的处理程序进行匹配。有没有办法让这个案例敏感?

1 个答案:

答案 0 :(得分:0)

我还没试过......但我认为它应该有用......

<bean id="handlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="pathMatcher" ref="myPathMatcher"/>
</bean>
<bean id="myPathMatcher" class="org.open.source.MyPathMatcher"/>

public class MyPathMatcher extends org.springframework.util.AntPathMatcher {
     @Override
     public Comparator<String> getPatternComparator(String path) {
        return new MyPathMatcherComparator(path);
    }
   }

public class MyPathMatcherComparator implements Comparator<String>
{
   public int compare(String pattern1, String pattern2) { 
        /* case sensitive logic goes here, simple return -1, 0, +1*/        
        /* check implementation of AntPathMatcher$AntPatternComparator for help... */
   }
}