将参数 id 传递到另一个页面

Passing parameter id onto another page

我想将 display.jsp table 中的学生 ID 传递到我的 student.jsp。我在获取学生 ID 时遇到问题。我无法显示或获取其值。请帮忙。谢谢

这是我的jdbc到select的id

public Student getStudentInfo(String id) {
        String SQL = "SELECT * FROM student WHERE id = ?";
        Event student = jdbcTemplateObject.queryForObject(SQL, new Object[] {id}, new StudentMapper());
        return student;

    }

display.jsp。 Table 包含我要传递的 ID 的学生信息

   <tbody>
        <c:forEach var="studentinfo" items="${display}">
    <tr>
    <td><c:out value="${studentinfo.id}"/></td>
    <td><c:out value="${studentinfo.name}"/></td>
    <td><c:out value="${studentinfo.age}"/></td>
    <td><c:out value="${studentinfo.bday}"/></td>
    <td><c:out value="${studentinfo.address}"/></td>
    <td><button type="submit" class="btn btn-danger btn-xs" name="deleteButton" value="${studentinfo.event_id}" onClick="return confirm('Are you sure you want to delete this student information?')"><i class="fa fa-times"></i>Delete</button>
<td>
<a href="${pageContext.request.contextPath}/student?id=${studentinfo.id}"><c:out value="${studentinfo.id}"/></a>
</td>
</td>
</tr>
 </c:forEach>
</tbody>

我的控制器

@RequestMapping("/student")
    public String studentinfo(HttpServletRequest request, ModelMap model){

        try
        {
        StudentJDBC = (Student)context.getBean("studentJDBC");
        System.out.println(request.getParameter("id"));
        studentJDBC.getStudentInfo(request.getParameter("id"));
        }
        catch(Exception e){
            System.out.print(e);
        }

        return "student";
    }

我想从这个 jsp

显示它
<html>
<body>
<label>Student Id</label>
                        <div class="form-group">
                            <span class="input-icon">
                                <span class="input-icon">
                                <input name="id" value="${studentinfo.id}"/>
                                </span>
                        </div>
</body>
</html>

您没有将查询的数据添加到新模型/请求中。因此,当您在 ${display} 上执行 <c:forEach> 时,它是空的。而且,您的显示应该是一个列表,符合您的 UI 代码,包含学生元素。