jquery:向后台提交数组

Posted huiy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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[] 必须这样写!

以上是关于jquery:向后台提交数组的主要内容,如果未能解决你的问题,请参考以下文章