Situation
I am creating a @RestController with spring-mvc to handle URLs like the following:
/api/products?attributes=brand:Audi,Mercedes&attributes=sector:Cars&...
I want to extract the @RequestParam List<AttributeValues> attributes in the corresponding method.
The AttributeValues.class does have a String name and Set<String> values that is used later to retrieve the products that match this query.
Problem
I tried to use the WebArgumentResolver but this does apparently not work for Lists. I am now searching for any advice on:
- How to implement a custom resolver for lists (multiple values for the same param)?
- Is there a better solution for structuring the (REST) URL for such a use-case (again, multiple values for the same argument)? I could change the format.
Requirements
The Product.class has a Set<Attribute> attributes and I can therefore not use URLs like /api/products?brand=Audi,Mercedes§or=Cars since these attributes could interfere with the properties on the Product.class.
Thank you for your help and advice.