@PostMapping public R save(@RequestBody Book book){ returnnew R(bookService.save(book)); } @PutMapping public R update(@RequestBody Book book){ returnnew R(bookService.modify(book)); } @DeleteMapping("{id}") public R delete(@PathVariable Integer id){ returnnew R(bookService.delete(id)); } @GetMapping("{id}")//主路径是books,下级目录为{id},即http://localhost:8080/books/{id},默认取下级目录的值作为id传入路径变量中 public R getById(@PathVariable Integer id){ returnnew R(true,bookService.getById(id)); }