在Servlet端获取html页面选中的checkbox值,request获取页面checkbox(复选框)值

html端代码:

适用人群:
<input type="checkbox" name="crowd" value="幼儿">幼儿
<input type="checkbox" name="crowd" value="青少年">青少年
<input type="checkbox" name="crowd" value="中年">中年
<input type="checkbox" name="crowd" value="老年">老年<br>

servlet代码:

//request获取页面checkbox(复选框)值
String[] crowd=request.getParameterValues("crowd");
String a="";
for(int i=0;i<crowd.length;i++)
a+=crowd[i]+",";
out.print("适用人群:"+a+"<br>");

猜你喜欢

转载自www.cnblogs.com/maaa/p/12532602.html