Hemachandra Hemachandra - 8 months ago 41
JSON Question

How to pass array in jquery ajax call and how to receive same from spring mvc controller

I am calling spring mvc controller method using jquery ajax.

jquery ajax call:

var filters = {KPI : visual, partnerName: params['partnerName'], itemQualifier: getItemQualifier(), currency : getCurrency(), sellSide: getSellSide()};

type: "POST",
url: "/reports/savefilters",
data: filters,
success: function(response){
alert('success: ' + response);
error: function(e){
alert('Error: ' + e.message);

Spring mvc code:

public void saveFilters(@RequestParam("KPI") String KPI, @RequestParam("partnerName") String partnerName,
@RequestParam("itemQualifier") String itemQualifier, @RequestParam("currency") String currency,
@RequestParam("sellSide") String sellSide){

Its working fine without "@RequestParam("partnerName") String partnerName" parameter.

Here "params['partnerName']" values are like abc,def,ghi.

Am I not sending data properly to controller???
Any suggestions how to make it work???. Thanks...



@RequestParam("partnerName") String partnerName


@RequestParam(value = "partnerName[]", required = false) String[] partnerName