Reputation: 61
I have two methods mapped with @GetMapping:
@GetMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, params = "test")
public String getTest(@RequestParam("test") String test) {
...
}
@GetMapping(path = "/some/path", produces = MediaType.APPLICATION_JSON_VALUE)
public String getTest() {
...
}
Is it possible to request to endpoint /some/path?test=string
be mapped
to first method, and request to endpoint some/path
be mapped to second method?
Upvotes: 0
Views: 194
Reputation: 130957
If I understand your issue correctly, you could use !test
as the value of params
:
@GetMapping(path = "/some/path",
params = "!test",
produces = MediaType.APPLICATION_JSON_VALUE)
Quoting the params
documentation:
[...] Expressions can be negated by using the
!=
operator, as inmyParam!=myValue
. [...] Finally,!myParam
style expressions indicate that the specified parameter is not supposed to be present in the request.
Upvotes: 1