标签 springBoot 设置spring mvc请求地址不区分大小写. 下的文章

在 spring boot项目的config目录下,创建,WebConfig类

71878-z1iaywlq24.png

代码如下,核心属性是matcher.setCaseSensitive(false);

import org.springframework.util.AntPathMatcher;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.context.annotation.Configuration;

/**
 * springBoot 设置spring mvc请求地址不区分大小写.
 */
@Configuration
public class WebConfig extends WebMvcConfigurationSupport {

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

}
免责声明
本博客部分内容来自于互联网,不代表作者的观点和立场,如若侵犯到您的权益,请联系[email protected]。我们会在24小时内进行删除。