关于spring boot url路径匹配斜杠“/”问题?

地址1:http://localhost:8762/hello
地址2:http://localhost:8762///hello

访问1 和访问2结果一样。

期望的是访问2返回404.

相关代码:

@RestControllerpublic class HelloController {    @GetMapping("hello")
    public String index() {        return "Hello World";
    }

}
@SpringBootApplicationpublic class EurekaClientApplication extends WebMvcConfigurationSupport {

    public static void main(String[] args) {        SpringApplication.run(EurekaClientApplication.class, args);
    }    @Override
    protected void configurePathMatch(PathMatchConfigurer configurer) {
        configurer.setUseSuffixPatternMatch(false)
                .setUseTrailingSlashMatch(false);
    }
}


函数式编程
浏览 3123回答 1
1回答

慕尼黑5688855

官方文档
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java