The front end code is as follows:
function ajaxClick() {
var arr = []
var jsont = {"name": "hejinghuan", "age": "23"};
var jsont2 = {"name": "yongzheng", "age": "33"};
var jsont3 = {"name": "huangdi", "age": "34"};
arr.push(jsont);
arr.push(jsont2);
arr.push(jsont3);
$.ajax({ // ajax login request
url: "ajaxdemo/test",
type:"POST",
data:{params:JSON.stringify(arr)},
async:false,
success:function(data){
alert(data);
}
});
}
Background code:
Here is the params, which is data:{params:JSON.stringify(arr)}. The key of the aqx passed in the parameter. After receiving it, convert the string to JSON with fastjson. Array.
@RestController
@RequestMapping("/ajaxdemo")
public class ajaxController {
@RequestMapping("test")
public String ajaxparam(@RequestParam String params) {
JSONArray paradms = JSON.parseArray(params);
for (int i = 0; i< paradms.size();i++) {
JSONObject paramjson = (JSONObject) paradms.get(i);
String name = paramjson.getString("name");
System.out.println(name);
}
System.out.println(params);
return params;
}
}
Traditional:true, : Prevents deep serialization and prevents data from being available in the background...
Hello Hello everyone: I still love Shenyangjava trainingThe Tsai, brought to you today is from the front desk ajax Detailed analysis and backstage pass to an array of problems. Welcome to the Markdown...
Here is the record I am using ajax to send data to the background, do the corresponding business logic operations backstage after receiving the data; the great God is ignored, the spray would not have...
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 tw...
The front end of the following code, passing an array, receiving background List <String>: Background code as follows: There are two points to note: Use annotations@RequestParam Parameter values...
Here the front desk pass over the json data format like this Here, if the background by directly receiving List is not enough, since the choice of solution and still a data array, direct access being ...
Reproduced in: https: //my.oschina.net/u/3055303/blog/878944...
The tablejsontest.json code is as follows:...
Later, I searched for information and found that although the data was loaded after the new node was added, the style was not loaded, so there are two points to note in the whole process. 1. Use loops...