<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">密码 :</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"> 性别 : <input type="radio" value="女" name="sgender" id="gender" value=<%=stu.getSgender() %>>女 <input type="radio" checked="checked" value="男" name="sgender" id="gender" value=<%=stu.getSgender() %>>男 </font> <br></p> <p align="center"> <font color="#c05887"> 出生日期:</font><input type="text" name="sbirthdate" class="ipt-t" value=<%=stu.getSbirthdate() %>> <br></p> <p align="center"><font color="#c05887"> 籍贯 : <select name="snativeplace" id="nativeplace" value=<%=stu.getSnativeplace() %>> <font color="#c05887"> <option value="浙江">浙江</option> <option value="上海">上海</option> <option value="江苏">江苏</option> </font> </select> </font> <br></p> <p align="center"><font color="#c05887">收货地址:</font><input type="text" name="saddress" value=<%=stu.getSaddress() %> ><br></p> <p align="center"> <font color="#c05887">电话 :</font><input type="text" name="stelphone" value=<%=stu.getStelphone() %>> <br></p> <p align="center"> </p> <div align="center"> </div><p align="center"> <input type="submit" value="更新用户"> <input type="reset" value="取消"> </p><p align="center"> <a href="/232dzy/zhuti/showyonghu.jsp"><< 返回用户列表</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界面,但是数据没有更新
可以把sql语句截取出来,放到数据库执行以下,看看语句是否有问题
没有问题