法一 通过URL传参 @GetMapping("/updateAdmin/{id}") public String updateAdmin(@PathVariable("id") int id){ String sqlUpdateAdmin = "update treehole.t_admin set name=?,password=? where id="+id ; Object[] objects = new Object[2]; objects[0]="b"; objects[1]="123"; jdbcTemplate.update(sqlUpdateAdmin,objects); return "update success"; } 法二 通过无类型数组objects传全部的参数 @GetMapping("/update2Admin") public String update2Admin(){ String sqlUpdate2Admin = "update treehole.t_admin set name=?,password=? where id=?" ; Object[] objects = new Object[3]; objects[0]="c"; objects[1]="456"; objects[2]=2; jdbcTemplate.update(sqlUpdate2Admin,objects); return "update2 success"; }