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
- create SampleController
|
|
- request the following URL
- 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 |
解决办法:
在 controller 上追加 requestMapping
解决 issue 为:
|
|