In grails, I have a Controller that expects a 'options' parameter that is sent via POST that can be a collection, i.e. 'options=A&options=B&options=C' which gets into grails, thanks to grails magic, as options = Collection of String with value ['A','B','C']. Problem is, when the user only picks one option, then the parameter becomes string and not string[] (or List) and when doing options.each then each, by groovy magic, gets processed character by character... how can I force options to be string[] or List so options.each is applied correctly?
In your action, you can always assume it as list like as follows:
List options = params.list('options')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With