日期:2014-05-17  浏览次数:20620 次

做WEB项目时遇到一个问题,请大侠帮忙解决一下
本帖最后由 u011613626 于 2013-08-31 22:26:13 编辑
代码如下:
   <%
   TeacherService service=new TeacherService();
  
   int TeachId=(Integer)session.getAttribute("TeachId");
   List<SelTopic> data=service.getAllSelTopic(TeachId);
    %>


   <form name="MyForm" action="Teacher/Topic/SelTopic.jsp" method="post">
<table border="1" cellpadding="5"  cellspacing="0" align="center" width="660">
     <tr height="50">
     <td width="120">学生编号</td>
     <td width="120">学生姓名</td>
     <td width="150">学生专业</td>
     <td width="120">状态</td>
     <td width="150" align="center">操作</td>
     </tr>
    <%for(SelTopic seltopic:data){ %>
     <tr height="30">
     <td ><%=seltopic.getStuNo() %></td>
     <td ><%=seltopic.getStuName() %></td>
     <td ><%=seltopic.getMajorName() %></td>
     <td><% if(seltopic.getSelState()==0){ out.print("未通过"); } else{ out.print("通过"); } %></td>
     <td align="center">
     <input type="hidden" name="Id" value="<%= seltopic.getId() %>"/>
     <input type="submit" name="Add" value="通过"/>
     <input type="submit" name="Delete" value="拒绝"/>
     </td>
     </tr>
<%} %>
</table>
</form>

        String Id=request.getParameter("Id");


不知道为什么点击任何一个按钮时,Id获得的总是列表里的第一个值,其对应的Id的值无法获取到,提交页面和处理页面是同一个页面。请各位大侠帮忙分析一下!

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