日期:2014-05-18  浏览次数:20712 次

struts中如何得到html:checkbox的个数?
checkbox的property都是chkSelect同一个名字
FormBean中属性设置为:
private   String[]   chkSelect;
那么如何得到页面中的checkbox的个数呢?

------解决方案--------------------
struts中checkbox对应后台的FormBean是Boolean形
LZ想实现HTML中的复选框的checkbox应该使用html:multibox
具体用法:
<html:multibox property= "interest " value= "看书 " /> 看书
<html:multibox property= "interest " value= "上网 " /> 上网
<html:multibox property= "interest " value= "游戏 " /> 游戏
<!-- <html:errors property= "interest "/> -> -- 这个不用也行
FormBean中对应
private String[] interest;
Action中Execute(..................){
String[] interests = registerForm.getInterest();//得到FormBean中的数组
}