标签:let cat jdk art 传输 分包 net cti dea
//方法一 使用POST+ _method:"DELETE" + filter(springboot不需要我们配置) //这里的传输对象为json对象,后台直接接受 var r=confirm("方法一:确认删除该条数据?"); if(r){ //var data = {_method:"DELETE", id:"456456",name:"征集"}; var data = {_method:"DELETE"};//_method:"DELETE"必须,其他属性看你需求 $.ajax({ url:"http://192.168.2.116:8080/pollution/delete/1786vdsds863", type:"POST", data:data, dataType:"json", success:function(result){ alert(result.msg); } }); }
@DeleteMapping("/pollution/delete/{id}") public ResponseData deletePollutionById(@PathVariable("id")String id, PollutionData data){ System.out.println(id); System.out.println(data); return new ResponseData(CodeEnum.SUCCESS.getCode(),MsgEnum.SUCCESS.getMsg(),null); }
2、
//方法二 使用DELETE请求 //这是的传输对象为json字符串 后台使用@RequestBody注解解析该字符串并将字符串映射到对应实体上 var r=confirm("方法二:确认删除该条数据?"); if(r){ var id = "123133"; var jsonstr = { id: id, name: "12345"}; console.log(jsonstr); $.ajax({ url:"http://192.168.2.116:8080/pollution/delete/" + id, type:"DELETE", contentType:"application/json",//设置请求参数类型为json字符串 data:JSON.stringify(jsonstr),//将json对象转换成json字符串发送 dataType:"json", success:function(result){ alert(result.msg); } }); } /**如果不需要传递参数,可以不写下面的几项 * contentType:"application/json",//设置请求参数类型为json字符串 data:JSON.stringify(jsonstr),//将json对象转换成json字符串发送 dataType:"json", */
@DeleteMapping("/pollution/delete/{id}") public ResponseData deletePollutionById(@PathVariable("id")String id, @RequestBody PollutionData data){ System.out.println(id); System.out.println(data); return new ResponseData(CodeEnum.SUCCESS.getCode(),MsgEnum.SUCCESS.getMsg(),null); }
参考:https://blog.csdn.net/liuyuanjiang109/article/details/78972644
标签:let cat jdk art 传输 分包 net cti dea
原文地址:https://www.cnblogs.com/threadj/p/9488810.html