ajax传递json对象数组到后台

版权声明:本文为yissan原创文章,未经本人允许严禁转载! https://blog.csdn.net/yissan/article/details/80509742

javascript 代码

$.ajax({
                type : "POST",
                traditional: true,
                contentType:'application/json;charset=UTF-8',
                url  : ctx + '/work/day/add',
                data : jsonStr,
                dataType : "json",
                success : function(data){
                    $.hideLoading();
                    if(data&&data.code==0){
                        $.toptip('工作日报提交成功', 'success');
                    }else{
                        $.toptip(data.message, 'error');
                    }
                },
                error : function(msg){
                    $.hideLoading();
                    $.toptip(msg, 'error');
                }
            });

后台接收参数代码

 @RequestMapping(value = "/day/add",method = RequestMethod.POST)
    @ResponseBody
    public CommonResult addPerformanceDay(
            @RequestBody PerformanceDayArgs.Add form,
            HttpServletRequest request

    ){
        .......
    }

实体类

public static class Add {


        @NotNull(message = "标题不能为空")
        private String title;
        private String des;
        @Min(0)
        private Long userId;
        @NotNull(message = "用户名称不能为空")
        private String userName;
        private Long workPlanId;
        @Min(0)
        private Long departmentId;
        @NotNull(message = "部门名称不能为空")
        private String departmentName;
        private List<PerformanceWorkArgs.Add> workList;
    }

猜你喜欢

转载自blog.csdn.net/yissan/article/details/80509742
今日推荐