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

Improve Javadoc for @RequestMapping#params #25482

Closed
behrangsa opened this issue Jul 28, 2020 · 2 comments
Closed

Improve Javadoc for @RequestMapping#params #25482

behrangsa opened this issue Jul 28, 2020 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task
Milestone

Comments

@behrangsa
Copy link

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 28, 2020
@sbrannen sbrannen changed the title Javadoc and implementation not inline for org.springframework.web.bind.annotation.RequestMapping#params Improve Javadoc for @RequestMapping#params Jul 28, 2020
@sbrannen
Copy link
Member

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"?

No. It is the combination of the URI and the request parameters that must be unique for this use case.

We'll improve the Javadoc there so that it is less misleading.

@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 28, 2020
@sbrannen sbrannen added this to the 5.3 M2 milestone Jul 28, 2020
@jhoeller jhoeller modified the milestones: 5.3 M2, 5.2.9 Aug 8, 2020
@jhoeller jhoeller self-assigned this Aug 10, 2020
@jhoeller
Copy link
Contributor

This is an outdated comment that refers to the behavior of our default HandlerMapping/Adapter implementation up until 4.3 and has no immediate relevance anymore today (except for other alternative implementations which may be out there still). I'll simply drop it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

4 participants