I am new to Struts 2. I want to send a javascript array to a Struts action class by using jQuery AJAX request.
The alert is working fine, the execute()
is
Jquery serializes data sent as parameters using $.param internally when doing ajax request with $.ajax.
The data should be set as array of integers or string with comma separated list of integers, so jQuery can correctly serialize it before sending with the request.
You can send an array parameter to struts2 only with traditional
setting because struts using type conversion to populate a property of the action using keys as parameter names.
So, the array should be an array of primitive integers but your array contains other objects that are not primitive integers.
To demonstrate you can see this demo to understand how to get parameter values and serialize it the same way like is doing $.ajax
.
Struts2 also can convert a string containing a comma separated values by default type conversion. For example you can see how checkbox list values are passed to struts action.