/* * Copyright (C) 2021 Anton Romanov - All Rights Reserved * You may use, distribute and modify this code, please write to: romanov73@gmail.com. * */ package ru.ulstu.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import ru.ulstu.news.NewsService; @Controller public class IndexController { private final NewsService newsService; public IndexController(NewsService newsService) { this.newsService = newsService; } @GetMapping("/") public String index(Model model) { model.addAttribute("news", newsService.getLast()); return "index"; } }