前端传递多个数组以及其他参数,springboot后台如何接收
前端传递参数ajax代码
var arr1=["1","2","3"];var arr2=["aa","bb","cc"];var id = 1;$.ajax({type: "post",//注意不能用getdataType: 'json',url: basePath+'/cmdb?id='id,data : {"arr1" : arr1,"arr2" : arr2},success:function(data){console.log(data);}})
后台接收参数代码
@RequestMapping("/cmdb")
@ResponseBody
public String saveRelation(@RequestParam(value = "arr1[]") String[] arr1,@RequestParam(value = "arr2[]") String[] arr2,Integer id) {return "ok";}