About the problem of spring boot url path matching slash "/"?

address 1: http://localhost:8762/hello
address 2: http://localhost:8762/hello

access 1 has the same result as access 2.

expect that access 2 returns 404.

related code:

@RestController
public class HelloController {

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

}
@SpringBootApplication
public 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);
    }
}
Apr.02,2021

setUseTrailingSlashMatch (true);
is set to true to be a strict match. You can return 404

.
Menu