控制台没有报错,但是无法更新数据

控制台没有报错,但是无法更新数据

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<html>
<head>
    <meta charset="utf-8">
    <title>欢迎来到苏州科技大学教师后台管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/css/theme.css">
    <link rel="stylesheet" type="text/css" href="/css/admin-forms.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
</head>

<body class="admin-validation-page" data-spy="scroll" data-target="#nav-spy" data-offset="200">
<div id="main">
    <header class="navbar navbar-fixed-top navbar-shadow">
        <div class="navbar-branding">
            <a class="navbar-brand" href="/index.html">
                <H3>苏州科技大学后台管理系统</H3>
            </a>
            <span id="toggle_sidemenu_l" class="ad ad-lines"></span>
        </div>
    </header>
    <aside id="sidebar_left" class="nano nano-light affix">
        <div class="sidebar-left-content nano-content">
            <header class="sidebar-header">
                <div class="sidebar-widget author-widget">
                    <div class="media">
                        <a class="media-left" href="#">
                            <img src="/images/head.jpg" class="img-responsive">
                        </a>
                        <div class="media-body">
                            <div class="media-author">杜景龙</div>
                            <div class="media-links">
                                <a href="login.html">退出</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="sidebar-widget search-widget hidden">
                    <div class="input-group">
                        <span class="input-group-addon">
                        <i class="fa fa-search"></i>
                        </span>
                        <input type="text" id="sidebar-search" class="form-control" placeholder="Search...">
                    </div>
                </div>
            </header>
            <ul class="nav sidebar-menu">
                <li class="sidebar-label pt20">学生信息</li>
                <li class="active">
                    <a href="${pageContext.request.contextPath}/index">
                        <span class="glyphicon glyphicon-book"></span>
                        <span class="sidebar-title">现有学生</span>
                    </a>
                </li>
                <li>
                    <a href="${pageContext.request.contextPath}/addusers.jsp">
                        <span class="glyphicon glyphicon-home"></span>
                        <span class="sidebar-title" >添加学生</span>
                    </a>
                </li>
                <li class="sidebar-label pt20">课程管理</li>
                <li class="active">
                    <a href="catalog_list.html">
                        <span class="glyphicon glyphicon-book"></span>
                        <span class="sidebar-title">学生成绩</span>
                    </a>
                </li>
                <li class="active">
                    <a href="catalog_list.html">
                        <span class="glyphicon glyphicon-book"></span>
                        <span class="sidebar-title">乔睿琪</span>
                    </a>
                </li>
                <li class="active">
                    <a href="catalog_list.html">
                        <span class="glyphicon glyphicon-book"></span>
                        <span class="sidebar-title">于佳民</span>
                    </a>
                </li>
                <li>
                    <a href="catalog_add.html">
                        <span class="glyphicon glyphicon-home"></span>
                        <span class="sidebar-title">添加课程</span>
                    </a>
                </li>
            </ul>
            <div class="sidebar-toggle-mini">
                <a href="login.html">
                    <span class="fa fa-sign-out"></span>
                </a>
            </div>
        </div>
    </aside>
    <section id="content_wrapper">
        <section id="content" class="table-layout animated fadeIn">
            <div class="tray tray-center">
                <div class="content-header">
                    <h2> 学生管理</h2>
                    <p class="lead"></p>
                </div>
                <div class="admin-form theme-primary mw1000 center-block" style="padding-bottom: 175px;">
                    <div class="panel  heading-border">
                        <div class="panel-menu">
                            <div class="row">
                                <div class="hidden-xs hidden-sm col-md-3">
                                    <div class="btn-group">
                                        <button type="button" class="btn btn-default light">
                                            <i class="fa fa-trash"></i>
                                        </button>
                                        <button type="button" class="btn btn-default light">
                                            <i class="fa fa-plus" onclick="javascript:window.location.href='cake_add.html';"></i>
                                        </button>
                                    </div>
                                </div>
                                <div class="col-xs-12 col-md-9 text-right">
                                    <form action="cake_list.html" method="post">
                                        共35条 1/2
                                        <div class="btn-group">
                                            <button type="submit" name="pageNum" value="0" class="btn btn-default light">
                                                <i class="fa fa-chevron-left"></i>
                                            </button>
                                            <button type="submit" name="pageNum" value="2" class="btn btn-default light">
                                                <i class="fa fa-chevron-right"></i>
                                            </button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>

                        <div class="panel-body pn">
                            <table id="message-table" class="table admin-form theme-warning tc-checkbox-1">
                                <thead>
                                <tr class="">
                                    <th class="hidden-xs">学生编号</th>
                                    <th class="hidden-xs">学生姓名</th>
                                    <th class="hidden-xs">课程名称</th>
                                    <th class="hidden-xs">年级</th>
                                    <th class="hidden-xs">成绩</th>

                                </tr>
                                </thead>

                            </table>
                        </div>
                        <tbody>
                        <c:forEach var="user" items="${gradeList}">
                            <tr class="message-unread">

                                <td class="hidden-xs"> ${user.uid} </td>
                                <td >${user.username}</td>
                                <td >${user.courseid}</td>
                                <td >${user.coursename}</td>
                                <td >${user.grade}</td>
                                <td>${user.chengji}</td>
                                <td><a href="${pageContext.request.contextPath}/Gradedetail?courseid=${user.courseid}">修改</a></td>
                                </td>
                            </tr>

                        </c:forEach>
                        </tbody>
                    </div>
                </div>
            </div>
        </section>
    </section>

</div>
<style>
    /* demo page styles */
    body { min-height: 2300px; }

    .content-header b,
    .admin-form .panel.heading-border:before,
    .admin-form .panel .heading-border:before {
        transition: all 0.7s ease;
    }
    /* responsive demo styles */
    @media (max-width: 800px) {
        .admin-form .panel-body { padding: 18px 12px; }
    }
</style>

<style>
    .ui-datepicker select.ui-datepicker-month,
    .ui-datepicker select.ui-datepicker-year {
        width: 48%;
        margin-top: 0;
        margin-bottom: 0;

        line-height: 25px;
        text-indent: 3px;

        color: #888;
        border-color: #DDD;
        background-color: #FDFDFD;

        -webkit-appearance: none; /*Optionally disable dropdown arrow*/
    }
</style>

<!-- jQuery -->
<script src="/js/jquery.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<!-- Theme Javascript -->
<script src="/js/utility.js"></script>
<script src="/js/demo/demo.js"></script>
<script src="/js/main.js"></script>
<script src="/js/pages.js"></script>
<!-- END: PAGE SCRIPTS -->
</body>
</html>
package com.damu.servlet;
import com.damu.dao.UsersDAO;
import com.damu.entity.Users;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/updategrades")
public class GradeUpdateServlet  extends HttpServlet{
    private UsersDAO usersDAO=new UsersDAO();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取用户要更新的数据
        String name=req.getParameter("name");
        String grade=req.getParameter("grade");
        String chengji=req.getParameter("chengji");
        System.out.println(name+grade+chengji);
        //创建用户对象
        Users user=new Users(name,grade,Integer.parseInt(chengji));
        System.out.println(user.getName()+user.getCourseid()+user.getChengji());
        //提交更新
        usersDAO.updateGrade(user);
        System.out.println(user.getName()+user.getCourseid()+user.getGrade());
        resp.sendRedirect("/Gradedetail?courseid="+user.getCourseid());

    }
}
package com.damu.dao;
import com.damu.entity.Users;
import com.damu.utils.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import java.util.List;
public class UsersDAO {
    private SqlSession sqlSession;
    private List<Users> list;
    private Users user;
    private SqlSession getSession() {
        sqlSession = SqlSessionFactoryUtils.getSqlSessionFactory().openSession();
        return sqlSession; }
    /**
     * 查询全部用户
     * @return
     */
    public List<Users> findAll() {
        try {
            list = getSession().selectList("findUsers");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 查询单个用户根据编号
     * @return
     */
    public Users findById(Integer id) {
        try {
            user = getSession().selectOne("findUsers",new Users(id));
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            sqlSession.close();
        }
        return user;
    }

    /**
     * 增加一个新用户到数据库的方法
     * @return
     */

    public Users addUser(Users user) {
        try {
            System.out.println("user==="+user);
            //返回值:是insert执行过程中影响的行数
            getSession().insert("addUser",user);
            sqlSession.commit();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            sqlSession.close();
        }
        return user;
    }
    /**
     * 查询全部用户的成绩
     * @return
     */
    public List<Users> findGrade() {
        try {
            list = getSession().selectList("findGrade");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            sqlSession.close();
        }
        return list;
    }
    /**
     * 查询单个用户根据成绩
     * @return
     */
    public Users GradefindById(String courseid) {
        try {
            user = getSession().selectOne("findGrade",new Users(courseid));
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            sqlSession.close();
        }
        return user;
    }
    /**
     * 修改成绩的方法
     * @return
     */

    public Users updateGrade(Users user) {
        try {
            System.out.println("user==="+user);
            //返回值:是insert执行过程中影响的行数
            getSession().update("updateGrade",user);
            sqlSession.commit();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            sqlSession.close();
        }
        return user;
    }
    /**
     * 用于修改用户资料的方法
     * @return
     */

    public Users updateUsers(Users user) {
        try {
            System.out.println("user==="+user);
            //返回值:是insert执行过程中影响的行数
            getSession().update("updateUser",user);
            sqlSession.commit();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            sqlSession.close();
        }
        return user;
    }
    /**
     * 用于删除用户资料的方法
     * @return
     */

    public void delUsers(Integer id) {
        try {
         getSession().delete("delUsers",id);
            //返回值:是insert执行过程中影响的行数

            sqlSession.commit();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            sqlSession.close();
        }

    }
}
package com.damu.entity;
import java.util.Date;
public class Users {
    private String name;
    private String grade;
    private String coursename;
    private Integer uid;
    private String courseid;
    private Integer chengji;
    private Integer age;//用户年龄
    private String gender;//用户性别
    private String phone;//用户电话联系
    private String email;//用户邮箱
    private String adress;
    private Date createTime;//账号创建时间
    private Date updateTime;//账号最后修改时间
    private Date lastLogin;//用户最后登录时间
    private Integer userState;//用户账号状态
    private String remark;
    private Integer id;//用户编号
    private String username;//登陆账号
    public Users(Integer age, String gender, String phone, String email, String adress, Date updateTime, String remark, Integer id) {
        this.age = age;
        this.gender = gender;
        this.phone = phone;
        this.email = email;
        this.adress = adress;
        this.updateTime = updateTime;
        this.remark = remark;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Users(String courseid) {
        this.courseid = courseid;
    }

    public Users(Integer id) {
        this.id = id;
        }
    public Users() {
    }
    public Users(Integer age, String gender, String phone, String email, String adress, Date createTime, Date updateTime, Date lastLogin, String username, String userpass,Integer userState) {
        this.age = age;
        this.gender = gender;
        this.phone = phone;
        this.email = email;
        this.adress = adress;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.lastLogin = lastLogin;
        this.username = username;
        this.userpass = userpass;
        this.userState=userState;
    }
    public Users(String username, String userpass, Integer age, String gender, String phone, String email, String adress, Date createTime, Date updateTime, Date lastLogin) {
        this.username = username;
        this.userpass = userpass;
        this.age = age;
        this.gender = gender;
        this.phone = phone;
        this.email = email;
        this.adress = adress;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.lastLogin = lastLogin;
    }
    private String userpass;//登陆密码
    public String getUserpass() {
        return userpass;
    }
    public void setUserpass(String userpass) {
        this.userpass = userpass;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public String getAdress() {
        return adress;
    }
    public void setAdress(String adress) {
        this.adress = adress;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Date getLastLogin() {
        return lastLogin;
    }
    public void setLastLogin(Date lastLogin) {
        this.lastLogin = lastLogin;
    }
    public Integer getUserState() {
        return userState;
    }
    public void setUserState(Integer userState) {
        this.userState = userState;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }
    public String getGender() {
        return gender;
    }
    public void setGender(String gender) {
        this.gender = gender;
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getCourseid() {
        return courseid;
    }
    public void setCourseid(String courseid) {
        this.courseid = courseid;
    }
    public Integer getChengji() {
        return chengji;
    }
    public void setChengji(Integer chengji) {
        this.chengji = chengji;
    }
    public Integer getUid() {
        return uid;
    }
    public void setUid(Integer uid) {
        this.uid = uid;
    }
    public String getGrade() {
        return grade;
    }
    public void setGrade(String grade) {
        this.grade = grade;
    }
    public String getCoursename() {
        return coursename;
    }
    public void setCoursename(String coursename) {
        this.coursename = coursename;
    }
    public Users(String grade, String coursename, String courseid) {
        this.grade = grade;
        this.coursename = coursename;
        this.courseid = courseid;
    }
    public Users(String name,String grade,Integer chengji) {
        this.grade = grade;
        this.chengji = chengji;
        this.name = name;
    }
}
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
    <meta charset="utf-8">
    <title>欢迎来到苏州科技大学教师后台管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/css/theme.css">
    <link rel="stylesheet" type="text/css" href="/css/admin-forms.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
</head>

<body class="admin-validation-page" data-spy="scroll" data-target="#nav-spy" data-offset="200">
<div id="main">
    <header class="navbar navbar-fixed-top navbar-shadow">
        <div class="navbar-branding">
            <a class="navbar-brand" href="/index.html">
                <H3>苏州科技大学后台管理系统</H3>
            </a>
            <span id="toggle_sidemenu_l" class="ad ad-lines"></span>
        </div>
    </header>
    <aside id="sidebar_left" class="nano nano-light affix">
        <div class="sidebar-left-content nano-content">
            <header class="sidebar-header">
                <div class="sidebar-widget author-widget">
                    <div class="media">
                        <a class="media-left" href="#">
                            <img src="/images/head.jpg" class="img-responsive">
                        </a>
                        <div class="media-body">
                            <div class="media-author">杜景龙</div>
                            <div class="media-links">
                                <a href="login.html">退出</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="sidebar-widget search-widget hidden">
                    <div class="input-group">
                        <span class="input-group-addon">
                        <i class="fa fa-search"></i>
                        </span>
                        <input type="text" id="sidebar-search" class="form-control" placeholder="Search...">
                    </div>
                </div>
            </header>
            <ul class="nav sidebar-menu">
                <li class="sidebar-label pt20">学生信息</li>
                <li class="active">
                    <a href="cake_list.html">
                        <span class="glyphicon glyphicon-book"></span>
                        <span class="sidebar-title">现有学生</span>
                    </a>
                </li>
                <li>
                    <a href="${pageContext.request.contextPath}/addusers.jsp">
                        <span class="glyphicon glyphicon-home"></span>
                        <span class="sidebar-title" >添加学生</span>
                    </a>
                </li>
                <li class="sidebar-label pt20">课程管理</li>
                <li class="active">
                    <a href="catalog_list.html">
                        <span class="glyphicon glyphicon-book"></span>
                        <span class="sidebar-title">学生成绩</span>
                    </a>
                </li>
                <li>
                    <a href="catalog_add.html">
                        <span class="glyphicon glyphicon-home"></span>
                        <span class="sidebar-title">添加课程</span>
                    </a>
                </li>
            </ul>
            <div class="sidebar-toggle-mini">
                <a href="login.html">
                    <span class="fa fa-sign-out"></span>
                </a>
            </div>
        </div>
    </aside>
    <section id="content_wrapper">
        <section id="content" class="table-layout animated fadeIn">
            <div class="tray tray-center">
                <div class="content-header">
                    <h2> 学生管理</h2>
                    <p class="lead"></p>
                </div>
                <c:set var="user" value="${user}"></c:set>
                <div class="row">
                    <div class="col-md-8 col-md-offset-2">
                        <form class="form-horizontal" action="${pageContext.request.contextPath}/updategrades">
                            <input type="hidden" name="uid" value="${user.courseid}">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">用户账号</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">${user.name}</p>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="chengji" class="col-sm-2 control-label">成绩</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="chengji" value="${user.chengji}" name="chengji"  placeholder="请输入成绩">
                                </div>
                            </div>
                            <div class="form-group">
                                <input type="submit" value="提交数据更新" class="btn btn-primary">
                            </div>
                        </form>
                    </div>
                </div>

            </div>
        </section>
    </section>

</div>
<style>
    /* demo page styles */
    body { min-height: 2300px; }

    .content-header b,
    .admin-form .panel.heading-border:before,
    .admin-form .panel .heading-border:before {
        transition: all 0.7s ease;
    }
    /* responsive demo styles */
    @media (max-width: 800px) {
        .admin-form .panel-body { padding: 18px 12px; }
    }
</style>

<style>
    .ui-datepicker select.ui-datepicker-month,
    .ui-datepicker select.ui-datepicker-year {
        width: 48%;
        margin-top: 0;
        margin-bottom: 0;

        line-height: 25px;
        text-indent: 3px;

        color: #888;
        border-color: #DDD;
        background-color: #FDFDFD;

        -webkit-appearance: none; /*Optionally disable dropdown arrow*/
    }
</style>

<!-- jQuery -->
<script src="/js/jquery.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<!-- Theme Javascript -->
<script src="/js/utility.js"></script>
<script src="/js/demo/demo.js"></script>
<script src="/js/main.js"></script>
<script src="/js/pages.js"></script>
<!-- END: PAGE SCRIPTS -->
</body>



</html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.damu.entity.Users">

    <!--<select id="findUsers" resultType="com.damu.entity.Users">-->
    <select id="findUsers" resultMap="forUsers">
        select * from users

        <if test="id != null">
            where id = #{id}
        </if>
    </select>
    <resultMap id="forUsers" type="com.damu.entity.Users">
    </resultMap>

    <select id="findGrade" resultMap="forGrade">
        select * from chengji

        <if test="courseid != null">
            where courseid = #{courseid}
        </if>
    </select>
    <resultMap id="forGrade" type="com.damu.entity.Users">

    </resultMap>
    <update id="updateGrade">
        UPDATE chengji
        <set>
            <if test="name!=null">name = #{name},</if>
            <if test="grade!=null">grade =#{grade},</if>
            <if test="chengji!=null">chengji =#{chengji},</if>
        </set>
        where courseid=#{courseid}
    </update>
    <insert id="addUser" useGeneratedKeys="true" keyProperty="id">
        insert into users(username,userpass,age,gender,phone,email,adress,createTime,updateTime,lastLogin,userState,remark)
       value(#{username},#{userpass},#{age},#{gender},#{phone},#{email},#{adress},#{createTime},#{updateTime},#{lastLogin},#{userState},#{remark})
    </insert>
    <update id="updateUser">
    UPDATE users
    <set>
        <if test="username!=null">username = #{username},</if>
        <if test="userpass!=null">userpass = #{userpass},</if>
        <if test="age!=null">age =#{age},</if>
        <if test="gender!=null">gender =#{gender},</if>
        <if test="phone!=null">phone =#{phone},</if>
        <if test="email!=null">email =#{email},</if>
        <if test="adress!=null">adress =#{adress},</if>
        <if test="createTime!=null">createTime =#{createTime},</if>
        <if test="updateTime!=null">updateTime =#{updateTime},</if>
        <if test="lastLogin!=null">lastLogin =#{lastLogin},</if>
        <if test="userState!=null">userState =#{userState},</if>
        <if test="remark!=null">remark =#{remark},</if>
    </set>
    where id=#{id}
</update>

    <delete id="delUsers">
        delete from users where id=#{id}
    </delete>
</mapper>

http://img1.sycdn.imooc.com//climg/5c9205790001c57118210824.jpg

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

3回答
好帮手慕珊 2019-03-22 19:56:11

你好!如下选中的内容,是一个Servlet吗?这个东西在哪?按照逻辑,应该是想通过这个Servlet查询出数据,然后在修改的jsp页面中去显示,你是这么完成的吗?

http://img1.sycdn.imooc.com//climg/5c94ccda0001676907670230.jpg

祝学习愉快!

  • 提问者 戏一 #1
    对的,我是这样的
    2019-03-22 20:12:13
  • 提问者 戏一 #2
    对的,我是这样的
    2019-03-22 20:12:14
  • chrismorgen 回复 提问者 戏一 #3
    你好~建议同学在该FGradedetetail中打印一下couresid的值,看在控制台中是否有输出信息呢?祝学习愉快~
    2019-03-24 16:30:56
好帮手慕阿莹 2019-03-21 15:41:31

老师的意思是:点击提交更新数据后,应该会跳入到updategrads对应的这个Servlet中,http://img1.sycdn.imooc.com//climg/5c933ee800015ce007560508.jpg

也就是下图这个Servlet中

http://img1.sycdn.imooc.com//climg/5c933f9200016ed307360503.jpg

我们在doPost()或者doGet()方法中,添加任意一个输出语句,比如:

 System.out.println(“1111111”);

看看点击提交更新数据后,有没有进入到这个Servlet中。

这样一步一步去测试,看看是为什么没有变化。

祝学习愉快。



  • 提问者 戏一 #1
    进入了servlet中,但是我在上面的参数并未传入,就是我修改的数据传入了,但是未修改的数据没有传入,然后用userdao包中的updategrade方法并未将这些数据传上去
    2019-03-22 17:29:27
  • 提问者 戏一 #2
    进入了servlet中,但是我在上面的参数并未传入,就是我修改的数据传入了,但是未修改的数据没有传入,然后用userdao包中的updategrade方法并未将这些数据传上去
    2019-03-22 17:29:27
  • 提问者 戏一 #3
    也就是说getparameter这个并没有获得我没有更改的数据,他只获得了我更改后的数据
    2019-03-22 17:32:20
好帮手慕阿莹 2019-03-20 19:36:05

因为没有办法帮同学测试,请同学再描述一下,

1、可以看一下另外两个控制台是否报错:

http://img1.sycdn.imooc.com//climg/5c9223e0000128f604430085.jpg

2、同学这的null 是哪里没有传好么?

http://img1.sycdn.imooc.com//climg/5c922426000110b112730664.jpg

3、

http://img1.sycdn.imooc.com//climg/5c92251a0001552c07820374.jpg

http://img1.sycdn.imooc.com//climg/5c9225740001638807650391.jpg

同学可以按照这个思路,看看到哪里进行不下去了,我们来一步一步的排查。或者同学可以debug一下。

祝学习愉快,

  • 提问者 戏一 #1
    老师所显示的第三张图的那里如何打印输出看是否传入呢? 第四张图上所显示的输出查看,我没有更改的数据并未上传,为null,我修改的为我所修改的数值。与我之前看老师上课的不同,老师的那个为未进行修改的,仍然有数据库中的数据,修改的则为修改的数据
    2019-03-20 19:51:24
  • 提问者 戏一 #2
    另外两个控制台也并未报错
    2019-03-20 20:01:23
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
Java数据库开发与实战应用2018版
  • 参与学习           人
  • 提交作业       277    份
  • 解答问题       4297    个

Java数据库开发的必备技能,从流行的MySQL数据库开始,到Java原生的数据库管理接口JDBC的使用,再到常用的数据持久化框架MyBatis,让你向Java工程师的目标又迈进了一步!

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师