Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 error occurs with RequestMapping(path="") #33499

Closed
koki8 opened this issue Dec 9, 2022 · 5 comments
Closed

404 error occurs with RequestMapping(path="") #33499

koki8 opened this issue Dec 9, 2022 · 5 comments
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@koki8
Copy link

koki8 commented Dec 9, 2022

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
  1. Check result
  • Expected value
    The string of 「Test」 is displayed
    Status:200

  • 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
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 9, 2022
@bclozel
Copy link
Member

bclozel commented Dec 9, 2022

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

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2022
@bclozel bclozel added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 9, 2022
@koki8
Copy link
Author

koki8 commented Apr 5, 2023

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

spring-projects/spring-framework#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
  1. confirmation result
  • Expected value
    • The string "test" is displayed.
    • Status:200
  • Actual result
    • 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

@bclozel
Copy link
Member

bclozel commented Apr 5, 2023

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

@koki8
Copy link
Author

koki8 commented Apr 6, 2023

@bclozel
spring-projects/spring-framework#29625
The duplicated SpringFramework issue is already closed, can you tell me which issue you are talking about?

@bclozel
Copy link
Member

bclozel commented Apr 6, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants