xenteros xenteros - 1 month ago 7
Java Question

Rest endpoint mapped with @PathVariables separated by comma

I have

. I have
for extracting certain entity.

@GetMapping(value = "/{firstId},{secondId}")
public ResponseEntity<MyResourceDTO> findMyResource(
@PathVariable Long firstId, @PathVariable String secondId) {

//here I have firstId == null and secondId == null

If I replace
everything works fine, but the requirement is not to use another

I can confirm, that I can enter this method, but both
s are mapped to null. Does
support this kind of mapping? What have I done wrong?

I would like to achieve something similar to this, but I must use


I have seen the solution with
but I don't want to use it, as the ids are of different type, so it's not a duplicate. I'm using

Answer Source

With your current Spring version, you can try using _ as the delimiter and it should work fine.

I read this once in a Spring Documentation, but can't find the link right now, will add it as soon as I find it.