6. 마찬가지로 BookController 클래스에 POST 방식의 submitAddNewBook() 메서드를 추가합니다.
코드 7-8 BookMarket/src/com/springmvc/controller/BookController.java
package com.springmvc.controller;
...
import org.springframework.web.bind.annotation.PostMapping;
@Controller
@RequestMapping("/books")
public class BookController {
...
@GetMapping("/add")
public String requestAddBookForm(@ModelAttribute("NewBook") Book book) {
return "addBook";
}
@PostMapping("/add") ➊
➋
public String submitAddNewBook(@ModelAttribute("NewBook") Book book) {
bookService.setNewBook(book); ➌
return "redirect:/books"; ➍
}
}