1, the front-end $.ajax data for JSON submission, the background method must use the @requestbody annotation
@RequestMapping (value = "Getcpudata/{interval}/{times}/{req_time}")//
@ResponseBody
Public Jsonobject Getcpumonitordata (httpservletrequest request, @PathVariable ("interval") int interval,
@PathVariable ("Times") int times,
@PathVariable ("Req_time") String Req_time,
@RequestBody jsonobject IP) {
2. The value of the Data property in the $.ajax method is either the {} object form or the string form.
For example, a JSON object needs to be converted into a string, and the background spring is automatically converted to a JSON object.
If the value of data is object {IP: "11.11.11.11"}
ip = {ip:["10.11.11.11", "10.11.11.11"]};
ip = json.stringify (IP);
Console.log ("\ n---IP:" +ip+ "" +json.stringify (IP));
Legend_cpu_data = new Array ();
var req_time=getdate ();
$.ajax ({
URL: "getcpudata/" +interval+ "/" +times+ "/" +req_time,
Type: "POST",
ContentType: ' Application/json;charset=utf-8 ',
Data:ip,
DataType: ' JSON ',
Success:function (Resdata, status) {
About the collation of the data field in $.ajax--including JSON conversion and spring annotations