Used version

SpringBoot3.0.0 GA

Occurrence event

When I specify an empty string in Controller's RequestMapping (@RequestMappint(path="")) and access the root path, The mapping doesn't work properly and I get 404. I could find the endpoint is created at startup, but the request never reaches the Controller. This event does not occur in SpringBoot3.0.0 M3. It has occurred since M4.

Reproduction steps below

  1. Create SampleController
@RestController
public class SampleController {

    @RequestMapping(path = "")
    public String demo(){
        return "test";
    }
}
  1. Request to the following URL
  2. 「http://localhost:8080/」
  3. 「http://localhost:8080」

  4. Check result

  5. Expected value
    The string of 「Test」 is displayed
    Status:200

  6. Actual
    Status:404

Supplement

  • If any character is present in the @RequestMapping of the class or method, it will be successfully mapped.

  • Confirmed for the following versions

SpringBoot version Result
2.7.6 OK
3.0.0 M3 OK
3.0.0 M4 NG
3.0.0 GA NG

Comment From: bclozel

Closing as a duplicate of spring-projects/spring-framework#29625

Comment From: koki8

@bclozel
It looks like the contents of this issue are not fixed.
I checked with SpringBoot 3.0.5 and the same issue occurred.

https://github.com/spring-projects/spring-framework/issues/29625
404 occurred when using @GetMapping as well as the above Controller.

See below for reproduction procedure

  1. create SampleController
@RestController
public class SampleController {

    @RequestMapping(path = "")
    public String demo(){
        return "test";
    }
}
  1. request the following URL
  2. 「http://localhost:8080」
  3. 「http://localhost:8080/」

  4. confirmation result

  5. Expected value
  6. The string "test" is displayed.
  7. Status:200
  8. Actual result
  9. Status:404

Supplementation

Occurrence Conditions

case SpringBoot ver2.7.10

request mapping expected actual OK/NG
localhost @RequestMapping 200 200 OK
localhost/ @RequestMapping 200 200 OK
localhost @RequestMapping(path = "") 200 200 OK
localhost/ @RequestMapping(path = "") 200 200 OK
localhost @RequestMapping(path = "/") 200 200 OK
localhost/ @RequestMapping(path = "/") 200 200 OK

case SpringBoot ver3.0.5

request mapping expected actual OK/NG
localhost @RequestMapping 200 404 NG
localhost/ @RequestMapping 200 404 NG
localhost @RequestMapping(path = "") 200 404 NG
localhost/ @RequestMapping(path = "") 200 404 NG
localhost @RequestMapping(path = "/") 200 200 OK
localhost/ @RequestMapping(path = "/") 200 200 OK

※The same phenomenon occurs with @GetMapping

Versions confirmed to work

  • Confirmed with the following version
SpringBoot version Result
2.7.6 OK
2.7.10 OK
3.0.0 M3 OK
3.0.0 M4 NG
3.0.0 GA NG
3.0.2 NG
3.0.3 NG
3.0.4 NG
3.0.5 NG

Comment From: bclozel

@koki8 This issue is a duplicate of a Spring Framework issue that is not fixed yet. So this is expected.

Comment From: koki8

@bclozel https://github.com/spring-projects/spring-framework/issues/29625 The duplicated SpringFramework issue is already closed, can you tell me which issue you are talking about?

Comment From: bclozel

Apologies I thought it was not done yet. It looks like the enhancement is incomplete, I've opened spring-projects/spring-framework#30293 to fix that.