In Spring Boot 2.6.7, I want to set up all of my Controllers' URLs to be case insensitive.
I tried this but not work
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
AntPathMatcher matcher = new AntPathMatcher();
matcher.setCaseSensitive(false);
configurer.setPathMatcher(matcher);
}
}
Can we configure it through application.properties file?
Please Help me. Thank you
CodePudding user response:
After @Xiidref solution could you add
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
in your application.properties
file.
CodePudding user response:
According to the documentation AntPathMatcher Documentation the boolean of the setCaseSensitive
should be false
to get a case insensitive behaviour.
So replace
matcher.setCaseSensitive(true);
By
matcher.setCaseSensitive(false);