The front end of the following code, passing an array, receiving background List <String>:
var arrayData = [];
arrayData.push("xxx");
arrayData.push("yyy");
$.post(url,{arrayData : arrayData},function(data,status) {
//do something
});
Background code as follows:
@RequestMapping("test")
@ResponseBody
public Message test(@RequestParam(value="arrayData[]") List<String> arrayData){
//do something
return data;
}
There are two points to note:
Note: if arrayData only one value, and this value has a comma, for example:
arrayData.push("xxx,yyy")
Such data, when received back, list there will be two elements, namely "xxx" and "yyy"
If there are a plurality of deployment arrayData values, for example:
arrayData.push("xxx,yyy")
arrayData.push("aaa,bbb")
Such data, received the background, it does not split apart, that list there will be two elements, namely, "xxx, yyy" and "aaa, bbb";
So, if by virtue of their own data, so try not to use a comma; if you want to transfer the data itself, so, it can be replaced with other characters first comma, and then the background reception, back to back.
surroundings Reception to pass parameters to the background Reception using ajax Background use springMVC Transmission parameters are a plurality of objects N JSON object and JSON string In SpringMVC ...
Sharing a js method of passing array parameters to the background controller has a good reference value and I hope to help everyone. passes the arguments to the string, so to convert the array to a st...
Regarding the tone of the front and back end, the parameters cannot receive the problem. If you encounter a back end of the color pen, the parameter format is not clear about the interface document an...
Preface As a front-end entry library, jQuery is one of the necessary skills for every front-end staff. The $.ajax() method in jQuery is one of the basic methods for data transmission between front and...
Postman correctly tests passing arrays, MVC receives array parameters Receive parameter @RequestParam ("ids") in the background Postman test The value of the array, the name needs to corresp...
When using ajax to pass values to the background, sometimes a field needs to pass multiple values, you need to use an array. By default, ajax's parameter traditional is false, ie jquery will deeply ...
Introduction: In many cases, the front desk parameter passed is an array, then spliced into a bad string of key parameters, it can be resolved as follows: 1, add "traditional:true"Paramete...
1. Convert to bean Front page js Code behind 2. Convert to list Note that to convert to list, you need to pass an array in the foreground, and use the List directly to receive in the background, as fo...
Idea: 1, the data to be transferred into the array 2, create a hidden form 3. Traverse the array, create a hidden <input> in the hidden form and assign it 4, submit the form ...
js: $.ajax({ cache: false, type: "POST", url: "/userdelete/", traditional: true, // add this to pass an array dataType:'json', async: true, data:{ids:ids}, success: function(data) ...