JSP页面无法通过EL表达式获取控制器中传到前端页面的学生列表,直接通过URL地址可以直接访问到学生列表
学生控制器
@RequestMapping("/listStu")
public String listStu(Model model){
List<Student> students = studentService.queryALL();
model.addAttribute("List1",students);
return "/pages/student/listStudent.jsp";
}
学生列表JSP
<table class="tableList">
<thead>
<tr>
<th>学号</th>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
<th>入学时间</th>
<th width="120px">操作</th>
</tr>
</thead>
<c:forEach items="${List1}" var="stu">
<tr>
<td>${stu.stuId}</td>
<td>${stu.stuName}</td>
<td>${stu.stuGender}</td>
<td>${stu.stuAge}</td>
<td>${stu.stuEntreTime}</td>
<td>
<button class="edit">
<i class="fa fa-edit"></i>
修改</button>
<button class="remove" >
<i class="fa fa-remove"></i>
删除</button>
</td>
</tr>
</c:forEach>
</table>
将所有的学生信息展示到JSP页面
首先你得保证你的students不是空值,然后你试着把model改为request,用request域来传值,如果还不行的话就得看你前端页面有关使用jstl的依赖装好没,再不行的话就打开debug,调试就知道哪里错了