<li>
<label class="enterText">供应商类别:</label>
<p class="enterRadio">
<input type="checkbox" value="固定收益" class="type" id="typeA" name="type"/>
<label for="typeA">固定收益</label>
</p>
<p class="enterRadio">
<input type="checkbox" value="浮动收益" class="type" id="typeB" name="type"/>
<label for="typeB">浮动收益</label>
</p>
<p class="enterRadio">
<input type="checkbox" value="基金" class="type" id="typeC" name="type"/>
<label for="typeC">基金</label>
</p>
<p class="enterRadio">
<input type="checkbox" value="保险" class="type" id="typeD" name="type"/>
<label for="typeD">保险</label>
</p>
<div class="Validform_checktip"></div>
</li>

checkbox在后台直接用数组接收,然后遍历就可以得到checkbox被选中状态的一个数组
String[] checkbox= request.getParameterValues("type"); //根据名字获得checkbox的值,注意是getParameters,后面要加上s,因为是一个数组
String typeString="";//定义一个数组接收checkbox
for(int i =0;i<checkbox.length;i++) //对checkbox进行遍历
{
typeString+=checkbox[i]+",";
}
typeString=typeString.substring(0,typeString.length()-1); //截取掉最后一个逗号

版权声明:本文为a347911原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。