tags:

views:

21

answers:

2

Grails 1.3.1

I am using a jQuery library that sends a serialized parameter map to the server and it is formatted like so....

item[]=1&item[]=2&item[]=3

In my controller, when I do println params, it comes out...

[item[]: [1, 2, 3]]

I can't seem to get this data out of params in my controller, however. What am I missing?

+1  A: 

An HTTP Post sends name/value pairs up to the web server. These names are based on the names within the given HTML form controls.

When duplicates exist, they're combined into a comma delimited list of values.

So, "item=1&item=2&item=3" becomes "item=1,2,3" on the server side. You can create an array from the comma delimited string and use the values. This is how you'll process selected items from a tag that allows multiple items to be selected.

If you want to keep the values separate, they'll have to use different names on your HTML form tags.

AndrewDotHay
Yes, I understand how that works. The problem I'm having is how to get the array from the params. params.item returns null.
Gregg
A: 

This worked...

params['items[]']

Gregg