Suppose the parameters that need to be passed to the background are:
var userid = [1,2,3];
var username=["a","b","c"];
Var school = "Hahahahahaha";
There are two simple methods:
1. Join Traditional to prevent depth serialization
JS code:
$.ajax({
url:"*****",
data:{
"userid":userid,
"username":username,
"school":school
},
dataType:"json",
type:"post",
Traditional: true, / / Prevent depth serialization
cache:false,
async:false,
success:function(){
....
}
});
Java code:
@requesMapping(value="/****", method=RequestMethod.POST)
@responseBody
public String testForAjax(
@RequestParam(value="userid") Integer[] userid,
@RequestParam(value="username") String[] username,
String school){
.....
}
2. Specify the parameter type
JS code:
$.ajax({
url:"*****",
data:{
"userid":userid,
"username":username,
"school":school
},
dataType:"json",
type:"post",
cache:false,
async:false,
success:function(){
....
}
});
Java code:
@requesMapping(value="/****", method=RequestMethod.POST)
@responseBody
public String testForAjax(
@RequestParam(value="userid[]") Integer[] userid,
@RequestParam(value="username[]") String[] username,
String school){
.....
}
Transmission data is an array SpeciesList as a parameter transmission Data with single double quotes as a parameter $("#goodsType h3").append("<span οnclick=\"tabShow(th...
In general, there may be some people in a parameter has more value, may be passed as a character-delimited form, such as a multiple checkbox on the page: Then get back and then separate parameters, th...
Easy submission (modal frame) form Don't have a label to get a tag for a label There are two submissions method oneCommonly used for events, automatically submit by default SecondFor form submission A...
Method 1: Method 2: [Java Interview Questions and Answers] Organize recommendations Basics and grammar set network programming Concurrent programming Web Safety Design Patterns fr...
Js to pass the array to the server C # receiving The editor did it temporarily, for reference only!...
A front end Backstage...
introduction: at work, sometimes after post will meet the parameters of the request for the case of an array, this situation should be how to solve it? As shown below: Idea 1: directly into the...
Foreword: When interacting with the backend in vue, use axios to send the request, and use the get request to pass the array type parameter without configuration. The backend cannot receive data, and ...
Arrays are passed as formal parameters When an array is passed as a formal parameter, it is passed as a pointer. //Although the forms are different, the above two functions are equivalent, and the onl...
A friend asked on the forum today: declare the function as void function (int** pInt), the intention is to pass a two-dimensional array of parameters. So we define a two-dimensional array, such as int...