SSM中前端jsp页面为什么获取不到model的值?

weixin_38058190 2019-01-29 09:34:56
这是控制器,可以打桩输出model的值 @RequestMapping(value = "handle_selectDatas", method = RequestMethod.POST) public String selectDatas(StudentModelStudent studentModelStudent,Model model){ List<StudentModelStudent>studentModelStudents= studentService.studentGetDats(studentModelStudent); model.addAttribute("StudentModelStudent",studentModelStudents); System.out.println(studentModelStudents); return "student"; } 这是jsp页面 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>学生信息表</title> </head> <body> <h1 align="center">学生信息管理</h1> <center> <form method="post" action="handle_selectDatas"> <p > 输入学号进行查询: <input name="sid" type="text"> <input value="查询" type="submit"> </p> </form> <form method="post"action="handle_selectDatas"> <p > 输入姓名进行查询: <input name="studentname" type="text"> <input value="查询" type="submit"> </p> </form> <form method="post" action="handle_selectDatas"> <p > 输入性别进行查询: <input name="gender" type="text"> <input value="查询" type="submit"> </p> </form> <form method="post" action="handle_selectDatas"> <p > 输入年龄进行查询: <input name="age" type="text"> <input value="查询" type="submit"> </p> </form> <form method="post" action="handle_selectDatas"> <p > 输入专业进行查询: <input name="" type="text"> <input value="查询" type="submit"> </p> </form> <form method="post" action="handle_selectDatas"> <p > 输入手机号进行查询: <input name="phone" type="text"> <input value="查询" type="submit"> </p> </form> </center> <table width="80%" border="1" align="center" class="gridtable" > <thead> <tr> <td colspan="8" align="center">学生信息管理</td> </tr> </thead> <tbody> <tr align="center"> <th>学号</th> <th>姓名</th> <th>年龄</th> <th>性别</th> <th>学科</th> <th>手机号</th> <th>操作</th> </tr> <tr> <td>${StudentModelStudent.sid}</td> <td>${StudentModelStudent.studentname}</td> <td>${StudentModelStudent.age}</td> <td>${StudentModelStudent.gender}</td> <td>${StudentModelStudent.specialty}</td> <td>${StudentModelStudent.phone}</td> <td> <a href="">删除</a> <a href="">修改</a> </td> </tr> </tbody> </table> <hr> <center> <a href="studentindex"><button type="button" style="height:35px">增加学生信息</button></a> </center> </body> </html> 这是最终显示页面 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core_1_1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Context-Type" content="text/html;charset=UTF-8"> <title>学生信息查询</title> </head> <body> <center> <h2>您查询<span style="color:red"></span>的信息如下:</h2> <table width="80% border="1" class="gridtable" align="center" > <tr align="center"> <th>学号</th> <th>姓名</th> <th>年龄</th> <th>性别</th> <th>学科</th> <th>手机号</th> <th>操作</th> </tr> <c:forEach items="${StudentModelStudents}" var="StudentModelStudents"> <tr> <td>${param.StudentModelStudents.sid}</td> <td>${param.StudentModelStudents.studentname}</td> <td>${param.StudentModelStudents.age}</td> <td>${param.StudentModelStudents.gender}</td> <td>${param.StudentModelStudents.specialty}</td> <td>${param.StudentModelStudents.phone}</td> <td><a href="${pageContext.request.contextPath }/deleteStudentById?id=${student.id} ">删除</a> <a href="${pageContext.request.contextPath }/updatestudent?id=${student.id} ">修改</a></td> </tr> </c:forEach> </table> </center> <br><br><br> </body> </html>
...全文
417 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38061732 2019-01-29
  • 打赏
  • 举报
回复
c:forEach有点问题,首先items和var相同了,其次param不需要吧

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧