js post
var obj={ classifyId:classifyId, packageName:packageName, packagePic:packagePic, packageDescribe:packageDescribe, packagePurchasePrice:packagePurchasePrice, equipList:equipArr }; console.log(obj); $.ajax({ url: PROJECT+"/r/equip/addPackage", type: "post", data:JSON.stringify(obj), contentType : "application/json; charset=utf-8", success: function(data) { console.log(data); } });
java 后台
@RequestMapping(value = "/addPackage",method = RequestMethod.POST) @ResponseBody public Reply addPackage(@RequestBody EquipPackageDto packageDto ) throws Exception{ Reply reply = new Reply(); //参数校验 return reply; }
js get
$.ajax({ url: url, type: "GET", data:"classifyId="+classifyId, dataType: "json", success: function(data) { console.log(data); } });
java get
@RequestMapping(value = "/listEquip",method = RequestMethod.GET) @ResponseBody public Reply listEquip(EquipTypeDto equipTypeDto) throws HugException{ Reply reply = new Reply(); return reply; }