【JS】【2】ajax传的参数为数组时,后台接收为null的处理

前言:

1,参考博客:解决JavaScript中使用$.ajax方式提交数组参数 - Just_Do - 博客园(http://www.cnblogs.com/caoyc/p/5710702.html

2,解决方案:添加traditional : true

正文:

js:

    var array = [];
    $("input").each(function(){
        array.push($(this).val());
    });

    $.ajax({
        type : "GET",
        traditional : true,//数组
        url : "/url",
        data : {
            "array" : array
        },
        success : function(list) {
            
        }
    });

后台:

   @ResponseBody
    @RequestMapping(value = "url", method = RequestMethod.GET)
    public void followDoctorList(String[] array)
    {
    }
原文地址:https://www.cnblogs.com/huashengweilong/p/7779674.html