Guest User

Untitled

a guest
May 24th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. ÐÐ¾Ð³Ð¾Ð»Ñ Ðиколай ÐаÑилÑевиÑ
  2.  
  3. @PostMapping("/add")
  4. public String add(@ModelAttribute("book")Book book, HttpServletRequest request){
  5. bookService.addBookWithAuthor(book, request.getParameter("author_name"), request.getParameter("author_years"));
  6. return "redirect:/home";
  7. }
  8.  
  9. @Override
  10. public void addBookWithAuthor(Book book, String author_name, String author_years) {
  11. Author author = new Author();
  12. author.setName(author_name);
  13. author.setYears(author_years);
  14. authorDao.saveAuthor(author);
  15. book.setAuthor(author);
  16. bookDao.addBook(book);
  17. }
Add Comment
Please, Sign In to add comment