我要修改zfy表中按序号sh修改表中记录
下面是显示数据列表的代码:
<%@ page import="java.util.*,java.sql.*" contentType="text/html;charset=GB2312" %>
<jsp:useBean id="pool" scope="application" class="com.cn.conn.ConnPool"/>
<jsp:include page="admin.jsp"></jsp:include>
<html>
<head>
<title>显示问候语</title>
</head>
<body>
<br/>
<br/>
<table border=1 align="center" width="80%">
<tr>
    <td>序号</td>
    <td>祝福语</td>
    <td>祝福语类型</td>
    <td>操作</td>
</tr>
<%  
    String exeid=request.getParameter("id");
    String work=request.getParameter("work");
    String sql="";
    Connection con=null;
  try
  {
      if(pool.getDriver()==null)
      {
      pool.setDriver("com.mysql.jdbc.Driver");
      pool.setURL("jdbc:mysql://localhost:3306/ningboxianxue");
      pool.setSize(5);
      pool.initializePool();
      }
      con=pool.getConnection();
      Statement statement=con.createStatement();
      ResultSet rs=statement.executeQuery("select * from zfy");
      while(rs.next())
      {
         String id=rs.getString("sh");
 %>   
     <tr>
         <td><%=rs.getInt(1)%></td>
         <td><%=rs.getString(2)%></td>
         <td><%=rs.getString(3)%></td>
         <td><a href="modify.jsp?id=<%=id%>">修改</a>/<a href="delete.jsp?work=delete&id=<%=id%>">删除</a></td>
     </tr>
<%
}
    rs.close();
    pool.releaseConnection(con);}
    catch(Exception e)
    {
        out.println(e.getMessage());
    }
    if(exeid!=null)
    {
        if(work.equals("delete"))out.println("<script>alert('您已成功删除该记录!');this.location.href='showzfy.jsp';</script>");
        else
            out.println("<script>alert('您已成功修改该记录!');this.location.href='showzfy.jsp';</script>");
    }
%>        
</table>
</body>
</html>点击修改进入修改页面:
<html>
  <head>
    <title>修改祝福语</title>
  </head>
  <%@ page import="java.util.*,java.sql.*" contentType="text/html;charset=gb2312" %>
  <jsp:useBean id="pool" scope="application" class="com.cn.conn.ConnPool"/>
  <body>
  <%
if(session.getAttribute("username")==null){response.sendRedirect("index.jsp");}
 %>
 <%
 String id=request.getParameter("id");
 String sql="";
  Connection con=null;
  try
  {
      if(pool.getDriver()==null)
      {
      pool.setDriver("com.mysql.jdbc.Driver");
      pool.setURL("jdbc:mysql://localhost:3306/ningboxianxue");
      pool.setSize(5);
      pool.initializePool();
      }
      con=pool.getConnection();
      Statement statement=con.createStatement();
      sql="select * from zfy where sh="+id+"";
      ResultSet rs=statement.executeQuery(sql);
      rs.next();
      String sh=rs.getString("sh");
%> 
<div align="center">修改第<%=sh%>条祝福语记录</div>
<br/>
<form method="post" action="delete.jsp?work=modify&id=<%=id%>" OnSubmit="return checkData();">
    <div align="center">
    祝福语内容<input type="text" name="whnr"/>
    <br/>
    <br/>
   祝福语类型<select name="whlx" >
               <option value="A" selected>
                   A
               <option value="B">
                   B
               <option value="C">
                   C
               <option value="D">
                   D
          </select>
    <br/>
    <br/>
    <input type="submit" value="确定"/>
    <input type="reset" value="重置"/>
    </div>
    </form>
<%
rs.close();
pool.releaseConnection(con);
          }
          catch(Exception e)
          {
              out.println(e.getMessage());
          }
%>
</body>
</html>
输入修改后的数据后,进入处理页面:
<html>
  <head>
    <title>删除祝福语</title>
  </head>
  <%@ page import="java.util.*,java.sql.*" contentType="text/html;charset=gb2312" %>
  <jsp:useBean id="pool" scope="application" class="com.cn.conn.ConnPool"/>
  <body>
  <%
if(session.getAttribute("username")==null){response.sendRedirect("index.jsp");}
 %>
<%
String id=request.getParameter("id");
String work=request.getParameter("work");
String sql="";
  Connection con=null;
  try
  {
      if(pool.getDriver()==null)
      {
      pool.setDriver("com.mysql.jdbc.Driver");
      pool.setURL("jdbc:mysql://localhost:3306/ningboxianxue");
      pool.setSize(5);
      pool.initializePool();
      }
      con=pool.getConnection();
      Statement statement=con.createStatement();
      if(work.equals("modify"))
      {   
          String sh=request.getParameter("sh");
          String whnr=request.getParameter("whnr");
          String whlx=request.getParameter("whlx");
          boolean valid=true;
          sql="update zfy set whnr='"+whnr+"',whlx='"+whlx+"'where sh='"+sh+"'";
          statement.executeUpdate(sql);
          response.sendRedirect("showzfy.jsp?id="+id+"&work=modify");
          }
      else
      {
          sql="delete  from zfy where sh='"+id+"'";
          statement.executeUpdate(sql);
          response.sendRedirect("showzfy.jsp?id="+id+"&work=delete");
      }
%>
<%
    pool.releaseConnection(con);
          }
          catch(Exception e)
          {
              out.println(e.getMessage());
          }
%>
</body>
</html>
里面的删除功能能正常实现,但是在修改数据后,能提示修改成功页面,但里面的数据一点没变,这是怎么回事呢?