//修改service
int update(Author author);
//修改 serviceImpl
@Override
@Transactional
public int update(Author author) {
return authorMapper.updateByPrimaryKey(author);
}
//修改controller
@PutMapping("update")
public ResponseEntity update(Author author){
int count=service.update(author);
System.out.println(count);
if(count>0){
return new ResponseEntity<>("修改成功",HttpStatus.OK);
}else {
return new ResponseEntity<>("修改失败",HttpStatus.BAD_REQUEST);
}
}
修改姓名: <input type="text" id="a_name" /> 修改 //根据id查询赋值 function selectId(id){ $.ajax({ url:"../author/"+id, type:"GET", success:function (author) { $("#a_id").val(author.aid); $("#a_name").val(author.aname); } }); } //修改 $("#btn").click(function () { //获得表单数据 var form=$("#form_add").serialize(); //发送ajax请求 $.ajax({ url:"../../author", type:"PUT", date: form, success:function (response) { console.log(response) } }); });