Method level only, empty RequestMapping matches "" and "/"

Closes gh-30293
This commit is contained in:
rstoyanchev
2023-06-12 16:09:49 +01:00
parent 3fb98b6a97
commit bbab4faf7a
7 changed files with 53 additions and 15 deletions

View File

@@ -61,6 +61,17 @@ class RequestMappingIntegrationTests extends AbstractRequestMappingIntegrationTe
}
@ParameterizedHttpServerTest // gh-30293
void emptyMapping(HttpServer httpServer) throws Exception {
startServer(httpServer);
String url = "http://localhost:" + this.port;
assertThat(getRestTemplate().getForObject(url, String.class)).isEqualTo("root");
url += "/";
assertThat(getRestTemplate().getForObject(url, String.class)).isEqualTo("root");
}
@ParameterizedHttpServerTest
void httpHead(HttpServer httpServer) throws Exception {
startServer(httpServer);
@@ -106,6 +117,11 @@ class RequestMappingIntegrationTests extends AbstractRequestMappingIntegrationTe
@SuppressWarnings("unused")
private static class TestRestController {
@GetMapping
public String get() {
return "root";
}
@GetMapping("/text")
public String textGet() {
return "Foo";