地址1:http://localhost:8762/hello
地址2:http://localhost:8762///hello
访问1 和访问2结果一样。
期望的是访问2返回404.
相关代码:
@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);
}
}
setUseTrailingSlashMatch(true);
设置为true为严格匹配。即可返回404