jsp中读取选中的checkbox多选的值

来源:互联网 发布:淘宝购买快递单号 编辑:程序博客网 时间:2024/05/29 03:52

 1.jsp

<form name="form" action="test2.jsp">
<br>

<input TYPE="checkbox" name="fruit" VALUE="apples"> Apples <BR>
<input TYPE="checkbox" name="fruit" VALUE="grapes"> Grapes <BR>
<input TYPE="checkbox" name="fruit" VALUE="oranges"> Oranges <BR>
<input TYPE="checkbox" name="fruit" VALUE="melons"> Melons <BR>

<br>
<input name="aa" type="submit" value="click" />

</form>

2.jsp

<%
String fruit[] =request.getParameterValues("fruit");
for(int i=0;i<fruit.length;i++){
out.println(fruit[i]);
}
%>

原创粉丝点击