前台代码:
<form action="" method="get">
您喜欢的水果?<br /><br />
<label><input name="Fruit" type="checkbox" value="1" />苹果 </label>
<label><input name="Fruit" type="checkbox" value="2" />桃子 </label>
<label><input name="Fruit" type="checkbox" value="3" />香蕉 </label>
<label><input name="Fruit" type="checkbox" value="3" />梨 </label>
</form>
后台代码:
public void save(HttpServletRequest request){
//获取选中的选项
String[] args=request.getParameterValues("Fruit");
}
假设四个全选中,则输出:[1,2,3,4];