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;
    }
阅读更多

扫码向博主提问

yissan

博客专家

非学,无以致疑;非问,无以广识
  • 擅长领域:
  • Android
  • Java Web
  • extjs
去开通我的Chat快问
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页