Skip to content

Commit

Permalink
Configuring Spring MVC Controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
DraconYale committed Apr 14, 2024
1 parent 80f6c35 commit 324b0d6
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package guru.springframework.spring5webapp.controllers;

import guru.springframework.spring5webapp.repositories.BookRepository;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class BookController {

private final BookRepository bookRepository;

public BookController(BookRepository bookRepository) {
this.bookRepository = bookRepository;
}

@RequestMapping("/books")
public String getBooks(Model model){

model.addAttribute("books", bookRepository.findAll());

return "books";
}
}

0 comments on commit 324b0d6

Please sign in to comment.