I don't think you need this logic, if you set the name of the checkboxes to be the same i.e type, then the browser always sends all checked ones to the server and spring will automatically convert them into a list or array.