如何从视图到控制器获取完整的对象

时间:2021-06-19 12:29:27

标签: html spring spring-boot spring-mvc

请帮助...我正在尝试获取对象老师并将其发送回控制器 我认为获取对象最好是获取电子邮件然后在数据库中获取它然后返回完整对象.... 请如何正确地做到这一点

<tbody>
                            <tr class="alert" role="alert" th:each="s : ${teachers}">
                              <th scope="row" th:text=${s.id}></th>
                              <td th:text=${s.fname}></td>
                              <td th:text=${s.lname}></td>
                              <td th:text=${s.getUser_id().email}></td>
                              <td  th:if="${banned}" th:text=${s.getUser_id().banedReason}></td>
                              <td style=" width:20%"><div>
                              <form style="display: inline-block;" action="/adminlogin/teacherEdit"  method="post">
                              <button class="buttonb" type="submit">Edit</button>
                              </form>

    @PostMapping("/adminlogin/teacherEdit")
    public String teacherEdit(@ModelAttribute Teacher teacher ,Model m ,RedirectAttributes r)
    {
        System.out.println(teacher.getFname());
        m.addAttribute("teacher",teacher);
        return "admin/editForm.html";
    }

enter image description here

0 个答案:

没有答案
相关问题