SpringMVC接收参数

数组参数

前端

var moduleids = moduleArr.join(',');  //一定要切换成,分割的字符串传到后台

后台

@RequestParam List moduleids
//或者String[] moduleids都可以接受,分割的字符串

不定个数参数

前端

layui框架

        //获取通讯方式并自动填充之前的配置
        $.ajax({
            url: "./warnwayjoinperson/getWarnwayForPerson"
            , data: {pcode:rowdata.code}
            , type: "post"
            , dataType: "json"
            , success: function (data) {
                var str = '';
                $.each(data, function (index, d) {
                    str += '<div class="layui-form-item">'
                            +'<label class="layui-form-label">'
                                +d.name
                            +'label>'
                            +'<div class="layui-input-block">'
                                +'<input type="text" name="'+d.code+'" value="'+(d.value==null?"":d.value)+'" autocomplete="off" class="layui-input">'
                            +'div>'
                           +'div>';
                });
                //放入html中
                $('#warnwayDiv').html(str);
                //渲染表单
                layui.use('form', function(){
                    var form = layui.form;
                    form.render("checkbox"); //渲染checkbox
                });
            }
            ,error:function(e){
                layer.alert("请求失败",{title:'提示',icon: 2});
            }
        });

后台

//接受参数qq:814,wechat:aeolian1995,phone:1535846
@RequestParam Map paramMap

 

点赞

Leave a Reply

Your email address will not be published. Required fields are marked *