开发者

Case Sensitive URL mapping in spring 3.0

开发者 https://www.devze.com 2023-01-16 07:48 出处:网络
Looks like the default annotations based handler mapping in spring 3.0 does case insensitive handler matching . Is there 开发者_StackOverflow社区a way to make this case sensitive ?I have not tried thi

Looks like the default annotations based handler mapping in spring 3.0 does case insensitive handler matching . Is there 开发者_StackOverflow社区a way to make this case sensitive ?


I have not tried this yet... but I think it should work....

<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... */
   }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消