jquery:向后台提交数组

var resArray = new Array(1,2,3);$.post(prefix + '/save/res/', {
        'roleID' : $('#roleID').val(),
        'resArray' : resArray,
    }, function(result) {
        top.closeLayer();
        if (result.state == 'succ') {
            top.refreshRight();
            top.okLayer('维护角色', '保存数据成功');
        } else {
            top.errorLayer('维护角色', '保存数据失败');
        }
    }, 'json');

后端接收,以springboot为例:

@RequestParam(name = "resArray[]", required = false) String[] resArray

resArray[] 必须这样写!

原文地址:https://www.cnblogs.com/huiy/p/12334291.html