跪求前辈又是Jsp问题进来看看啊!跪求跪求跪求 诡异的错误
userlist.jsp用来获取数据库中的用户信息 以表格的形式返回 点击修改时连接打到useredit.jsp
<body>
<form action="" method="post">
<table border="1">
<th>编号</th><th>用户名</th><th>密码</th><th>操作</th>
<%
String sql="SELECT bh,yhm,mm FROM user";
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "mysql");
Statement statement=conn.createStatement();
ResultSet rs=statement.executeQuery(sql);
while(rs.next())
{
int bh=rs.getInt(1);
String yhm=rs.getString("yhm");
String mm=rs.getString("mm");
out.print("<tr>");
out.print("<td>"+bh+"</td>");
out.print("<td>"+yhm+"</td>");
out.print("<td>"+mm+"</td>");
out.print("<td><a href='dodelete.jsp?id="+bh+"'>删除</a> <a href='useredit.jsp?id="+bh+"'>修改</a></td>");
out.print("</tr>");
System.out.print(bh);
}
conn.close();
statement.close();
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
%>
</table>
</form>
</body>
useredit.jsp 用来获取用户数据库中的信息
<%
String sql="SELECT yhm,mm FROM user WHERE bh="+Integer.parseInt(request.getParameter("id"));
String name="";
String mm="";
String path="";
int id=0;
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection c=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","mysql");
Statement s=c.createStatement();
ResultSet rs=s.executeQuery(sql);
System.out.print(sql);
if(rs.next())
{
name=rs.getString("yhm");
mm=rs.getString("mm");
id = rs.getInt("bh");
}
else
{
name="";
mm="";
}
path = "update.jsp?id=" + id;
c.close();
s.close();
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
%>
<form action="<%=path %>" method="post">
用户名:<input type="text" name="username" value="<%=name %>"/><br>
密码:<input type="password" name="password" value="<%=mm %>"/><br>
确认密码:<input type="password" name="qrpassword"/><br>
<input type="submit" value="提交"/>
<input type="reset" value="取消"/>
</form>
</body>
update.jsp 用来执行更新
<%
String yhm=request.getParameter("yhm");
String mm=request.getParameter("mm");
String sql="UPDATE user SET yhm=?,mm=? WHERE bh="+request.getParameter("id");
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection c=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","mysql");
PreparedStatement ps=c.prepareStatement(sql);
ps.setString(1, yhm);
ps.setString(2, mm);
ps.executeUpdate();
int result=ps.executeUpdate();
System.out.println(sql);
if(result==1)
{
out.print("更新成功!");
response.sendRedirect("userlist.jsp");
}
else
{
out.print("更新失败!");
}
}
catch(Exception e)
{
e.printStackTrace();