前端实现:
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); }
本文展示了一个简单的前端与后端交互的例子,使用了JSON格式的数据传输方式,并通过$.ajax发起POST请求,后端通过@RequestMapping接收请求并打印接收到的学生信息。
350

被折叠的 条评论
为什么被折叠?



