Skip to content

16. View Student Feature Backend

Ramesh Fadatare edited this page Jul 26, 2022 · 1 revision

Add view post button in Students Page

           <a th:href="@{/students/{studentId}/view(studentId=${student.id})}" class="btn btn-info">View</a>

Add viewStudent handler method in StudentController

    // handler method to handle view student request
    @GetMapping("students/{studentId}/view")
    public String viewStudent(@PathVariable("studentId") Long studentId,
                              Model model){
        StudentDto studentDto = studentService.getStudentById(studentId);
        model.addAttribute("student", studentDto);
        return "view_student";
    }