Your checkbox has currently no value associated with the parameter name at all:
<input type="checkbox" name="chkBox">
So it's hard to find out the checked ones. You need to give the checkbox a value which uniquely identifies the selected item. In your particular example, the student ID seems to be an obvious choice:
<input type="checkbox" name="selected" value="${student.studentID}">
(by the way, why are you duplicating the entity name in the property name? why not just name it id
so that you can just self-documentary use ${student.id}
? also your var="students"
is kind of odd, it is referring only one student, so just name it var="student"
; the ${studentList}
can better be named ${students}
)
When the form is submitted, all checked value are available as follows:
String[] selectedStudentIds = request.getParameterValues("selected");
Finally, just pass it through to your DAO/service class which does the business job:
studentService.delete(selectedStudentIds);
See also:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…