Okay I tested it in a new "Spring Environment" created on start.spring.io
It works out of the box, as already one in the comments said, but only with an Array of Integers (Not with a Set).
If you are gonna use one of the listed options you can remove duplicates of numbers (I guess this was your intention by using a Set) just with Set<Integer> ints = Arrays.stream(params).collect(Collectors.toSet())
When there definitely will be no "empty" number:
@GetMapping("/intarray")
public Object someGetMapping(int[] params){
return params;
}
http://localhost:8080/api/intarray?params=1,2,3,4,5,3
Output (As expected an array of integers):
[
1,
2,
3,
4,
5,
3
]
And if there's probably an empty number in it, I would suggest to use Integer as an array.
@GetMapping("/intset")
public Object someOtherGetMapping(Integer[] params){
return params;
}
http://localhost:8080/api/intset?params=1,2,3,4,5,,,5
Output (with null values because there are empty fields in the query):
[
1,
2,
3,
4,
5,
null,
null,
5
]