ajax请求springboot

老是忘记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;
}
 可以参考这个:https://blog.csdn.net/wangmx1993328/article/details/95042420

 

posted @ 2023-06-15 14:14  王短腿  阅读(41)  评论(0编辑  收藏  举报