ajax传递json对象数组到后台

前端之家收集整理的这篇文章主要介绍了ajax传递json对象数组到后台前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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;
    }
原文链接:https://www.f2er.com/ajax/160299.html

猜你在找的Ajax相关文章