I was reading regarding the @Matrixvariable annotation in Spring doc Spring Doc
I have Understood this simple syntax // GET /pets/42;q=11;r=22
@RequestMapping(value = "/pets/{petId}", method = RequestMethod.GET)
public void findPet(@PathVariable String petId, @MatrixVariable int q) {
// petId == 42
// q == 11
}
but having problem in understanding the below snippet
// GET /owners/42;q=11;r=12/pets/21;q=22;s=23
@RequestMapping(value = "/owners/{ownerId}/pets/{petId}", method = RequestMethod.GET)
public void findPet(
@MatrixVariable Map<String, String> matrixVars,
@MatrixVariable(pathVar="petId"") Map<String, String> petMatrixVars) {
// matrixVars: ["q" : [11,22], "r" : 12, "s" : 23]
// petMatrixVars: ["q" : 11, "s" : 23]
}
What is this syntax @MatrixVariable(pathVar="petId"") I haven't understood the pathVar attribute of Matrixvariable annotation?
This line is ok for me // matrixVars: ["q" : [11,22], "r" : 12, "s" : 23] that this variable added with all the matrix variables.
but how does petMatrixVars added with these Specific values mean
//petMatrixVars: ["q" : 11, "s" : 23] ? why not //petMatrixVars: ["q" : 22, "s" : 23] ?
Thanks in Advance for your time spent on this thread!!