I'm having issues trying to pass multiple values for a request param, for example.
I currently have this
http://localhost:8080/api/posts/search?brand=audi
But would like something like this
http://localhost:8080/api/posts/search?brand=audi&brand=bmw&brand=xxx
I'm using @RequestParam(required = false) List<String> brand,, but when I call a method in my Service class to find the values, I'm not sure how to be able to get all the values from the RequestParam, ie. brand=audi&brand=bmw, I don't know how to get all of those when passing the arugment to my findAllByBrand() method.
// When calling this from my Controller, how do i ensure i capture all possible request params
pageTuts = postService.findAllByBrand(pagingSort, ?);
From Service Class
public Page<Post> findAllByBrand(Pageable pageable, String brand) {
Page<Post> page = postRepository.findAllByBrand(pageable, brand);
if(page.isEmpty()) throw new PostNotFoundException("There are no matching records..");
return page;
}
Same with my Repository Interface, I currently have this.
@Query("From Post p WHERE p.brand LIKE %:brand% ORDER BY p.price ASC")
Page<Post> findAllByBrand(Pageable pageable, String brand);