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
Comment From: sbrannen
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.
Comment From: jhoeller
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.