package com.example.demo.controller; import com.example.demo.service.StudentService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("/students") public class StudentController { private final StudentService studentService; public StudentController(StudentService studentService){ this.studentService = studentService; } @GetMapping public String getAllStudents(Model model){ model.addAttribute("students", studentService.getAllStudents()); return "students"; } }