SpringBoot RequestBody ajax提交对象

前端实现:

var student = {
    "name":1,
    "age":2,
    "score":3
};
$.ajax({                                
    url:"student/test/delStudentByPrimaryKey.action",
    contentType:"application/json;charset=UTF-8",
    type:'POST',
    dataType:'json',//json 返回值类型
    data: JSON.stringify(student),//转化为json字符串
    success:function(data){
    }
});

后端实现:

@RequestMapping(value = "/delStudentByPrimaryKey")
void deleteByPrimaryKey(@RequestBody Student student){
        System.out.println(student);
}

 

posted @ 2018-09-17 16:41  chenzheng8975  阅读(342)  评论(0编辑  收藏  举报