Accessing a list of params in controller

后端 未结 1 780
后悔当初
后悔当初 2021-02-04 21:41

Im very new to grails (1.3.7) so please be patient :-)

I have a gsp where I have various checkboxes. A user can click on them and then send his answer to a controller. T

相关标签:
1条回答
  • 2021-02-04 21:55

    It must be passed as an extra request parameter (it's a limitation of http). You can add following field into your form, for example:

    <input type="hidden" name="checkboxes" value="${myCheckboxesNames.join(',')}"/>
    

    or making same using JavaScript, as it names are dynamic on client side.

    BTW, you can also check all request parameters, by

    params.each { name, value ->
    // so something
    }
    

    so if you are using some special prefix/suffix for this checkbox names, it would be:

    params.entrySet().findAll {
       it.key.startsWith(prefix)
    }.each {
       println "Checkbox $it.key = $it.value"
    }
    
    0 讨论(0)
提交回复
热议问题