personalweb

archived
git clone git://git.wimdupont.com/personalweb.git
Log | Files | Refs | LICENSE

BookController.java (695B)


      1 package com.wimdupont.personalweb.controller.web;
      2 
      3 import com.wimdupont.personalweb.service.BookService;
      4 import org.springframework.stereotype.Controller;
      5 import org.springframework.ui.Model;
      6 import org.springframework.web.bind.annotation.GetMapping;
      7 import org.springframework.web.bind.annotation.RequestMapping;
      8 
      9 @Controller
     10 @RequestMapping("/books")
     11 public class BookController {
     12 
     13     private final BookService bookService;
     14 
     15     public BookController(BookService bookService) {
     16         this.bookService = bookService;
     17     }
     18 
     19     @GetMapping
     20     public String getBooks(Model model) {
     21         model.addAttribute("books", bookService.findAllSortedByCategory());
     22         return "books";
     23     }
     24 
     25 }