@RequestMapping(value = "/book/delete/{isbn}", method = RequestMethod.GET) public ModelAndView delete(@PathVariable String isbn) { if (bookService.getBookByIsbn(isbn) == null) { return getErrorView("This book is not exist"); } bookService.delete(isbn); ModelAndView modelAndView = new ModelAndView("books"); modelAndView.getModel().put("books", bookService.findAll()); return modelAndView; }
@RequestMapping(value = "/book/get", method = RequestMethod.GET) public Iterable<Book> getAllBooks() { Iterable<Book> books = bookService.findAll(); return books; }
@RequestMapping(value = "/index", method = RequestMethod.GET) public ModelAndView index() { ModelMap model = new ModelMap(); model.put("books", bookService.findAll()); return new ModelAndView("books", model); }