Wednesday, January 26, 2022

AntPathMatcher replace with PathPatternParser

AntPathMatcher setCaseSensitive not working?

Did you update the version of Spring Boot? Did your URI case insensitivity stop working?

Did you have something like this:

@Configuration

public class WebConfig implements WebMvcConfigurer

{

    @Override

    public void configurePathMatch(PathMatchConfigurer configurer)

    {

        AntPathMatcher matcher = new AntPathMatcher();

        matcher.setCaseSensitive(false);

        configurer.setPathMatcher(matcher);

    }


Change it to something like this:


@Configuration

public class WebConfig implements WebMvcConfigurer

{

    @Override

    public void configurePathMatch(PathMatchConfigurer configurer)

    {

        PathPatternParser patternParser = new PathPatternParser();

        patternParser.setCaseSensitive(false);

        configurer.setPatternParser(patternParser);

    }

If you want to continue to use AntPathMatcher, add this to your application.properties file:

spring.mvc.pathmatch.matching-strategy=ant-path-matcher


No comments: