Как отобразить скрытую таблицу, когда указанный c путь контроллера вызывает файл html? - PullRequest
0 голосов
/ 01 мая 2020

Мне нужно показать соответствующую таблицу в файле html, когда вызывается заданный путь контроллера c. То есть, когда вызывается / student / list, он должен показывать таблицу с id = hiddenStTable; когда вызывается / course / list, необходимо показать таблицу с id = hiddenCrTable. Ниже вы можете найти скрипты частей моего контроллера и html.

<body>
<table style="width:80% display:none" id = "hiddenStTable">
    <tr>
        <th>ID</th>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Gender</th>
        <th>Degree</th>
        <th>Major</th>
        <th>GPA</th>
        <th>Email</th>
        <th>Graduation Date</th>
        <th>Courses</th>
    </tr>
    <tr th:each="student : ${students}">
        <td th:text="${student.studentId}">No data</td>
        <td th:text="${student.firstName}" >No data</td>
        <td th:text="${student.lastName}">No data</td>
        <td th:text="${student.gender}">No data</td>
        <td th:text="${student.degree}">No data</td>
        <td th:text="${student.major}">No data</td>
        <td th:text="${student.gpa}">No data</td>
        <td th:text="${student.emailAddress}">No data</td>
        <td th:text="${student.gDate}">No data</td>
        <td>
            <select>
                <option th:each="course : ${student.courses}" th:text="${course.courseName}" th:value="${course.courseId}"></option>
            </select>
        </td>
    </tr>
</table>

<table style="width:80% display:none" id = "hiddenCrTable">
    <tr>
        <th>ID</th>
        <th>Course name</th>
        <th>Available term</th>
        <th>Credit</th>
        <th>Type</th>
        <th>Instructor</th>
    </tr>
    <tr th:each="course : ${courses}">
        <td th:text="${course.courseId}">No data</td>
        <td th:text="${course.courseName}" >No data</td>
        <td th:text="${course.term}">No data</td>
        <td th:text="${course.courseCredit}">No data</td>
        <td th:text="${course.courseType}">No data</td>
        <td th:text="${course.courseInstructor}">No data</td>
    </tr>
</table>
</body>
@GetMapping("/course/list")
    public String getCourseList(Model model) {
        Iterable<Course> courses = courseRepo.findAll();
        model.addAttribute("courses", courses);
        return "show";
    }
@GetMapping("/student/list")
    public String getStudentList(Model model) {
        Iterable<Student> students = studentRepo.findAll();
        model.addAttribute("students", students);
        return "show";
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...