日期:2014-05-20  浏览次数:20769 次

Web开发获取数据重复问题
先放上代码
HTML code

<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.voole.vol_prj.sysmgr.domain.*" %> 
<%@ page import="com.voole.vol_prj.manager.*" %>   

<%
    request.setCharacterEncoding("UTF-8");
    String command = request.getParameter("command");
    String value = request.getParameter("prj_id");
//    out.print(value);
        
        if ("add".equals(command)) {    
            MemInfo info = new MemInfo();
            info.setPrj_member(request.getParameter("prj_member"));
        //    System.out.println(request.getParameter("prj_member"));
            info.setPrj_responsibility(request.getParameter("prj_responsibility"));
            info.setPrj_id(request.getParameter("prj_id"));
            MemberManager.getInstance().addMember(info);
            out.println("添加成员成功!");
        }

%>    
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>添加成员分工</title>
    
</head>
     <body>
   
     <h1 align="center">成员分工</h1>
     
     <form   id="prj_member" action="member_add.jsp" method="post"> 
       <input type="hidden" name="command" value="add">
       <input type="hidden" name="prj_id" value="<%= request.getParameter("prj_id")%>">
        <table width="88%" height="91">
        <tr bgcolor="F1FAFE">
        <td width="28%"></td>
        <th width="18%"><div align="left">成员</div></th>
        <th width="54%"><div align="left">职责</div></th>
        </tr>
         <%
                    String prjid = request.getParameter("prj_id");
                    List <MemInfo> infoList = MemberManager.getInstance().findMemberInfo(prjid);
                    for (Iterator<MemInfo> iter = infoList.iterator(); iter.hasNext();) {
                        MemInfo meminfo = iter.next();
                        
        %>
       <tr bgcolor="#F1FAFE">
                    <td> </td>
                
                    <td>
                        <%=meminfo.getPrj_member()%>
                    <br></td>
                    <td >
                        <%=meminfo.getPrj_responsibility() %>
                    <br></td>   
                    
                    
                </tr>
                <%
                    }
                 %>
        <tr>
          <td></td>
          <td><input type="text" name="prj_member"/></td>
          <td><input type="text" size="80" name="prj_responsibility"/></td>
          </tr>   
     </table>    
        <br>
    <div align="center">  <input name="close"  type="button" value="关闭" onClick="window.close()" />&nbsp; &nbsp; &nbsp;&nbsp;<input name="add"  type="submit" value="添加"  /> </div>

     </form>
        
 </body>
    
</html>




再说说现在的问题,我现在添加一条记录时没问题,添加过的数据也能在上一行显示
添加第二条的时候,显示的记录把第一条记录显示两遍,
也就是上一次的显示的记录没有覆盖,显示记录的方法是根据id从数据库读出来的
怎么修改
论坛没法传本地图片,不然能把问题描述的更明了些

------解决方案--------------------