ajax 多数组传参 后台接收格式

var projectIds = ["1", "2"]
            var shipIds = ["1", "2", "3", "6", "7", "8", "9", "10"]
            $.ajax({
                type:"get",
                dataType:"json",
                url:baseURL+"lxsj/lqxbsjproject/xcbMerge",
                data:{"projectIds":projectIds,"shipIds":shipIds},
                contentType:"application/json",
                traditional: true,//这里设置为true,默认情况下traditional为false,即jquery会深度序列化参数对象
                success:function (r) {

                }
            });
  /**
     * 合并上报
     */
    @ResponseBody
    @RequestMapping("/xcbMerge")
    public void xcbMerge(final String[] projectIds,final String[] shipIds) {
       
        for (String id:projectIds){
            System.out.println(id);
        }
        for (String ids:projectIds){
            System.out.println(ids);
        }

    }

 

你可能感兴趣的:(java,js)