我想将学生的id从display.jsp表传递给我的student.jsp。我有问题获得学生的身份。我无法展示或获取其价值。请帮忙。谢谢
这是我的jdbc选择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。包含我想传递的身份的学生信息表
<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>
答案 0 :(得分:1)
您没有将查询的数据添加到新模型/请求中。因此,当您在<c:forEach>
上执行${display}
时,它是空的。此外,您的显示应该是根据您的UI代码列出的,具有学生元素。