开发者

Case Sensitive URL mapping in spring 3.0

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜