Results 1 to 3 of 3

Thread: Spring 3.0 case insensitive urls

  1. #1
    Join Date
    Jan 2011
    Posts
    6

    Default Spring 3.0 case insensitive urls

    I am using Sping 3.0 and I am trying to make it so my controller will treat paths like /test/SomeVar/a the same as /Test/somevar/a.

    I found an older post in here http://forum.springsource.org/showthread.php?t=32654 that discussed AntPathMatcher.

    That looks like what I need to do but I am not sure where or how to configure this in 3.0.

    Any help would be much appreciated.

    Thanks

  2. #2
    Join Date
    Jan 2011
    Posts
    6

    Default Getting closer I think

    Ok I created a the following class:

    Code:
    public class CaseInsensitivePathMatcher extends AntPathMatcher {
    
    	@Override
    	public boolean match(String pattern, String string) {
    		String test = pattern.replace("{state}", "*");
    		boolean match = super.match(test.toLowerCase(), string.toLowerCase());
    		System.out.println("pattern: " + test.toLowerCase() + " = " + "string: " + string.toLowerCase() + " " + match);
    		return match;
    	}
    }
    I then added this configuration to my spring-servlet.xml:

    Code:
    	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    		<property name="pathMatcher">
    			<bean class="com.symmetry.spring.CaseInsensitivePathMatcher"/>
    		</property>		
    	</bean>
    When the application is deployed I can see the output and a match is found. But when I change a character in the url from lower case to uppercase I get a 404 error.

    Not sure where to go from here.

  3. #3
    Join Date
    Nov 2011
    Posts
    1

    Default Same problem!

    Hi. I am having the same issue. Did you ever get this issue solved?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •