Skip to content

400 Bad Request for missing URI template variable is incorrect [SPR-13121] #17712

Closed
@spring-projects-issues

Description

@spring-projects-issues

Yi EungJun opened SPR-13121 and commented

If I have a controller which has a method whose RequestMapping is incorrect as follows:

@RestController
public class HelloController {
    @RequestMapping("/test/{a}")
    public String test(@PathVariable String b) {
        return "ok";
    }
}

Then I request '/test/1' the server will response with 400 Bad Request as follows:

{"timestamp":1434182424954,"status":400,"error":"Bad Request","exception":"org.springframework.web.bind.ServletRequestBindingException","message":"Missing URI template variable 'b' for method parameter of type String","path":"/test/aaa"}

But 400 Bad Request is incorrect for this situation because it was not a client error but a server error, because there is no way to request correctly without modifying the server.


Affects: 4.1.6

Issue Links:

Referenced from: commits 4b05bda

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions