首页 新闻 会员 周边 捐助

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

0
解决于 2019-01-30 11:42

这是控制器,可以打桩输出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>

9257001的主页 9257001 | 初学一级 | 园豆:103
提问于:2019-01-29 21:34
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册