如何在servlet中获取单选按钮组值?

时间:2016-06-02 06:10:40

标签: jsp servlets radio-button

我想从jsp格式的选定单选按钮获取值到我的servlet。如何在servlet中获取值,提前感谢任何帮助。

Jsp page is:

    <table class="table" id="attendanceTableId" style="width: 500px;">
    <%
    for(int i=0;i<=se.size()-1;i++) {
    %>
      <tr>
         <td><input type="textbox" name="studentName" value="<%=se.get(i)%>" style="background-color: #A7C5C2" readonly></td>

         <td><input type="radio"  name="status_<%= i %>" value="Present" style="width: 15px; height: 15px;" />Present

         <input type="radio" name="status_<%= i %>" value="Absent" style="width: 15px; height: 15px;">Absent</td>
      </tr>

    <%
    }
    %>
    </table>    

1 个答案:

答案 0 :(得分:0)

您希望将此值与您在表单

中实现的值相同
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
   for(int i=0;i<=se.size()-1;i++) {
      String Status = request.getParameter("status_"+i);
   }
}