老是忘记ajax请求格式,记录一下吧后面看自己的
function save(){ var URL = "/reconciliation/wzglWzMaterilApplicationDetail/saveSupplier"; var cc=JSON.stringify({ data: "world", p: { pag: 0, pageSize: 0, total: 0 }, token: "string" }); $.ajax({ type: "post", contentType: "application/json",//必须项 dataType: "json",//必须项 data: cc, // async: true, url: URL, success: function (res) { console.log(res); }, error: function (err) { console.log("请求失败", err.statusText); } }); }
/**
* springboot后台
*/
@ResponseBody
@RequestMapping(value = "/saveSupplier", produces={MediaType.APPLICATION_JSON_VALUE}, consumes={MediaType.APPLICATION_JSON_VALUE}, method=RequestMethod.POST)
public HashMap saveSupplier(@RequestBody HashMap[] json) {
HashMap map=new HashMap();
map.put("id","2");
map.put("applyform_id","applyform_id");
map.put("material_id","material_id");
map.put("supplier","supplier");
return map;
}
标签:map,springboot,ajax,put,HashMap,id,请求 From: https://www.cnblogs.com/doumenwangjian/p/17482741.html