source: src/main/java/com/example/cookbook/controller/VrabotenController.java@ cab1b7d

Last change on this file since cab1b7d was cab1b7d, checked in by Blazho <aleksandar.blazhevski@…>, 5 months ago

Added naracki page with view of all

  • Property mode set to 100644
File size: 911 bytes
Line 
1package com.example.cookbook.controller;
2
3
4import com.example.cookbook.model.Naracka;
5import com.example.cookbook.service.NarackiService;
6import org.springframework.stereotype.Controller;
7import org.springframework.ui.Model;
8import org.springframework.web.bind.annotation.GetMapping;
9
10import java.sql.SQLException;
11import java.util.List;
12
13@Controller
14public class VrabotenController {
15
16 private final NarackiService narcakiService;
17
18 public VrabotenController(NarackiService narcakiService) {
19 this.narcakiService = narcakiService;
20 }
21
22
23 @GetMapping("/naracki")
24 public String getNaracki(Model model){
25
26 List<Naracka> naracki = null;
27 try {
28 naracki = narcakiService.listAll();
29 } catch (SQLException e) {
30 return "redirect:/error-page/SQL%20Exception";
31 }
32 model.addAttribute("naracki", naracki);
33 return "naracki";
34 }
35}
Note: See TracBrowser for help on using the repository browser.