SpringBoot RequestBody ajax提交对象
原创
©著作权归作者所有:来自51CTO博客作者风云正的原创作品,请联系作者获取转载授权,否则将追究法律责任
前端实现:
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);
}