失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > ajax传递数组到controller

ajax传递数组到controller

时间:2019-04-08 20:15:49

相关推荐

ajax传递数组到controller

使用ajax传递数组数据到controller:

JavaScript

$.ajax({

url: '/example',

type: 'POST',

data: {'arrays[]': [1, 2, ..., n]},

success: function(data){

console.debug(data);

}

})

Java

@ResponseBody

@GetMapping(value = "/example", produces = {"application/json;charset=UTF-8"})

public String example(@RequestParam(value = "arrays[]", required = false) Integer[] arrays){

log.debug(arrays.length);

return "提交成功!";

}

如果觉得《ajax传递数组到controller》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。