What’s the difference between the JAX-RS @QueryParam and @MatrixParam?
From the documents.The queryparam and matrixparam both can location one resource in special condition. So what’s the use case difference?
ps:
Queryparam:
url ? key=value;
Matrixparam
url; key=value;
As stated in this Oracle documentation:
Example (drawn from here):
See following URI patterns and result:
URI Pattern : “/books/2012/”
getBooks is called, year : 2012, author : null, country : null
URI Pattern : “/books/2012;author=andih”
getBooks is called, year : 2012, author : andih, country : null
URI Pattern : “/books/2012;author=andih;country=germany”
getBooks is called, year : 2012, author : andih, country : germany
URI Pattern : “/books/2012;country=germany;author=andih”
getBooks is called, year : 2012, author : andih, country : germany
For an explanation of the difference you may have a look at
URL matrix parameters vs. request parameters