首页 新闻 会员 周边 捐助

为什么数据更新不了

0
[待解决问题]

<body>
  
              <p style="font-size:35px; margin-left:390px;"> 顾客注册信息</p>
             <p style="font-size:25px; margin-left:390px;"> 欢迎<%=request.getParameter("user") %>管理员</p><br>
    <a href="pass.jsp?name=<%=session.getAttribute("user")%>">修改密码</a>
    <table id="tb" >
    <tr><td>ID</td><td>用户名</td><td>密码 </td><td>重复密码</td>
       <td>出生日期</td><td>收货地址</td><td>电话</td></tr>
    <%
    Soperator sop=new Soperator();
    List list=sop.findAll();
    Iterator it=list.iterator();
    while(it.hasNext()){
        Student stu=(Student)it.next(); 
    
     %>
     <tr><td><%=stu.getSid() %></td><td><%=stu.getSusername() %></td>
         <td><%=stu.getSuserpass() %></td><td><%=stu.getSreuserpass() %></td>
         </td><td><%=stu.getSbirthdate() %></td>
         <td><%=stu.getSaddress() %></td>
         <td><%=stu.getStelphone() %></td>
         <td><a href="/232dzy/zhuti/deleteyonghu.jsp?id=<%=stu.getSid()%>"style="color:red">删除</a>|
              <a href="/232dzy/zhuti/updateyonghu.jsp?id=<%=stu.getSid()%>" style="color:red">更新</a></td>
     </tr>
     <%} %>
    </table>
  </body>

 

public void updateStudent(Student stu) throws SQLException{ String sql="update student set stu_username=?, stu_userpass=?,stu_reuserpass=?,stu_gender=?,stu_birthdate=?,stu_nativeplace=?,stu_address=?,stu_telphone=? where stu_id=?"; PreparedStatement pst=con.prepareStatement(sql); pst.setString(1, stu.getSusername()); pst.setString(2, stu.getSuserpass()); pst.setString(3, stu.getSreuserpass()); pst.setString(4, stu.getSgender()); pst.setString(5, stu.getSbirthdate()); pst.setString(6, stu.getSnativeplace()); pst.setString(7, stu.getSaddress()); pst.setString(8, stu.getStelphone ()); pst.setInt(9, stu.getSid()); pst.executeUpdate(); }
  <form method="post" action="zhuti/testupdate.jsp" name="form1" ><div align="center"> </div>
           <input type="hidden" name="sid" value=<%=stu.getSid() %>>
    <div align="center"> </div>
    <div align="center"> </div>
    
    <p align="center"><font color="#c05887">用户名 :</font><input type="text" name="susername" value=<%=stu.getSusername() %>><br></p>
    <p align="center"><font color="#c05887">密码 &nbsp; :</font><input type="password" name="suserpass" value=<%=stu.getSuserpass() %>><br></p>
    <p align="center"><font color="#c05887">重复密码:</font><input type="password" name="sreuserpass" value=<%=stu.getSreuserpass() %>><br></p>
    <p align="center"><font color="#c05887">&nbsp; 性别&nbsp; &nbsp; :   
    <input type="radio" value="女" name="sgender" id="gender" value=<%=stu.getSgender() %>>女&nbsp;&nbsp;&nbsp;   
    <input type="radio" checked="checked" value="男" name="sgender" id="gender" value=<%=stu.getSgender() %>>男&nbsp;&nbsp;&nbsp;</font>&nbsp;&nbsp;   
    <br></p>

    
    <p align="center">&nbsp;<font color="#c05887"> 出生日期:</font><input type="text" name="sbirthdate" class="ipt-t" value=<%=stu.getSbirthdate() %>>&nbsp; <br></p>
    <p align="center"><font color="#c05887">&nbsp; 籍贯&nbsp;&nbsp;&nbsp; :&nbsp;<select name="snativeplace" id="nativeplace" value=<%=stu.getSnativeplace() %>>   
<font color="#c05887">
<option value="浙江">浙江</option>   
<option value="上海">上海</option>   
<option value="江苏">江苏</option> 
</font>  
</select>&nbsp; &nbsp; </font>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <br></p>
<p align="center"><font color="#c05887">收货地址:</font><input type="text" name="saddress" value=<%=stu.getSaddress() %> ><br></p>
<p align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#c05887">电话&nbsp;&nbsp; :</font><input type="text" name="stelphone" value=<%=stu.getStelphone() %>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br></p>
<p align="center"> </p>
<div align="center"> 
    </div><p align="center"> <input type="submit" value="更新用户"> <input type="reset" value="取消">&nbsp;</p><p align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="/232dzy/zhuti/showyonghu.jsp">&lt;&lt; 返回用户列表</a><br></p>
    </div>
    </form>
  </body>

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:useBean id="stu" class="bean.Student">
<jsp:setProperty name="stu" property="*"/>
</jsp:useBean>
<jsp:useBean id="sop" class="bean.Soperator"/>
<%
sop.updateStudent(stu);
response.sendRedirect("showyonghu.jsp");
%>

 点击更新后,可以收到数据库传来的数据,点击更新数据后,也能跳到showyonghu.jsp界面,但是数据没有更新


挚爱丶林的主页 挚爱丶林 | 初学一级 | 园豆:110
提问于:2016-06-01 21:59
< >
分享
所有回答(1)
0

可以把sql语句截取出来,放到数据库执行以下,看看语句是否有问题

wangYiYi | 园豆:13 (初学一级) | 2016-06-03 11:43

没有问题

支持(0) 反对(0) 挚爱丶林 | 园豆:110 (初学一级) | 2016-06-03 12:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册