jsp怎样接收复选框的参数值
有没有让jsp接收复选框的参数值更方便的方案呢?
在一个页面中有一组同名复选框,我在另一个页面中得到这组复选框提交的多选参数值
例如:<form name="form1" action="xxx.jsp" method="post">
<input type="checkbox" name="checkbox2" value="1">
<input type="checkbox" name="checkbox2" value="2">
<input type="checkbox" name="checkbox2" value="3">
</form>
假如我选中了第一个和第二个,我在xxx.jsp中得到他们的值
那么checkbox2里面就包括了"1","2",它们是可以通过函数分开的,只是我也只是在ASP里边用过,对于JSP我还是新手
String[] checkbox2 = request.getParameterValues("checkbox2");
String[] result = request.getParameterValues("checkbox2");
for (int i = 0; result != null && i < result.length; i++){
String resultStr = reault[i];
}
jsp有没提供更好的方案来解决这个问题呢?