我在把请求post改成put后,就发现后端接收不了数据,只知道一个用于增加一个用于修改,不知道怎么让put携带一个类的数据
用post时是可以的,把post改成put后就会报500,我应该怎么写才能让他携带一个实体类
@PostMapping("updateMedicineByMid")
@ResponseBody
public JsonResult<Void> updateMedicineByMid(Medicine medicine){
medicineService.updateMedicineByMid(medicine);
return new JsonResult<>(200);
}
$("#sure").click(
function deleteMedicineList(){
$.ajax({
url:"${pageContext.request.contextPath}/updateMedicineByMid",
type:"post",
data:$("#updateForm").serialize(),
dataType:"json",
success:function(json){
if(json.state == 200)
location.href = "${pageContext.request.contextPath}/medicineList.jsp";
},
error:function (json){
alert("失败")
}
})
}
)