获取servlet中td元素的每个输入值?

时间:2016-06-01 07:28:32

标签: html jsp servlets

我是servlets和JSP的新手。我的JSP页面中有一个表,我希望使用for循环然后save来获取所有值。我无法通过servlet中的标记名称遍历表中的数据,我只获得表的第一个td值。我不知道我犯了什么错误。

这是我的代码:

<table class="table table-hover" id="attendanceTableId">
    <%for(int i=0;i<=se.size()-1;i++) {%>
        <tr>
            <td><input type="textbox" name="studentName"  value="<%=se.get(i)%>" readonly></td>
            <td><input type="checkbox" name="status" value="present" style="width:15px;height:15px;"/>Present</td>
            <td><input type="checkbox" name="status" value="absent" style="width:15px;height:15px;">Absent</td>
        </tr>
    <%} %>
</table>

servlet是:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String rowCount=request.getParameter("rowCountHidden");
    int rowCountNum=Integer.parseInt(rowCount);
    System.out.println("rocount is"+rowCountNum);

    for (int i=1;i<=rowCountNum;i++) {
        String date=request.getParameter("date");
        String StudentName=request.getParameter("studentName");
        String status=request.getParameter("status");

        System.out.println("rocount is"+StudentName);
    }
}

0 个答案:

没有答案