Commit 95d9b113 by Patryk Czarnik

blog - lekkie zmiany

parent 03bc8d35
...@@ -14,7 +14,8 @@ public class BlogController { ...@@ -14,7 +14,8 @@ public class BlogController {
private BlogService blogService; private BlogService blogService;
@GetMapping @GetMapping
public String rozmowaGet() { public String rozmowaGet(Model model) {
model.addAttribute("teksty", blogService.getTeksty());
return "blog.html"; return "blog.html";
} }
......
...@@ -14,9 +14,13 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -14,9 +14,13 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/blog.json") @RequestMapping("/blog.json")
public class BlogRestController { public class BlogRestController {
@Autowired
private BlogService blogService; private BlogService blogService;
// innym sposobem wstrzykiwania zależności, niż @Autowired, jest utworzenie konstruktora, który wymaga podania parametru - wtedy Spring musi go dostarczyć
public BlogRestController(BlogService blogService) {
this.blogService = blogService;
}
@GetMapping @GetMapping
public List<String> getTeksty() { public List<String> getTeksty() {
return blogService.getTeksty(); return blogService.getTeksty();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment