How can I have case insensitive URLS in Spring MVC with annotated mappings

Dave picture Dave · Nov 11, 2010 · Viewed 22.5k times · Source

I have annotated mappings working great through my spring mvc web app, however, they are case sensitive. I cannot find a way to make them case insensitive. (I'd love to make this happen within Spring MVC, rather than redirecting traffic somehow)

Answer

npcode picture npcode · Jul 29, 2015

Spring 4.2 will support case-insensitive path matching. You can configure it as follows:

@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        AntPathMatcher matcher = new AntPathMatcher();
        matcher.setCaseSensitive(false);
        configurer.setPathMatcher(matcher);
    }
}