Skip to content

Improve Javadoc for @RequestMapping#params #25482

@behrangsa

Description

@behrangsa

In the Javadoc comments for org.springframework.web.bind.annotation.RequestMapping#params, it is noted that:

The primary path mapping (i.e. the specified URI value) still has to uniquely identify the target handler, with parameter mappings simply expressing preconditions for invoking the handler.

Does that mean as far as Spring is concerned, these handler methods are "invalid" then, as the URI does not "uniquely identify the target handler"?

@RestController
@RequestMapping(path = "/demo1")
public class DemoController1 {

    @GetMapping(params = "p=1")
    public String endpoint1(@RequestParam("p") final String p) {
        return p;
    }

    @GetMapping(params = "p=2")
    public String endpoint2(@RequestParam("p") final String p) {
        return p;
    }

}

If that's the case, Spring should throw an error during startup or print a warning, but it doesn't.

And FWIW, requests can be routed to endpoint1/endpoint2 based on value of p so maybe the Javadoc comment is out of date?

For context, see: https://gitter.im/spring-projects/spring-boot?at=5f1ef4e6e9066820051edccd

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation task

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions