单选按钮控件 struts使用单选按钮的三种方式
struts使用单选按钮的三种方式
struts中使用单选按钮有三种方式
使用<:option>标签
<:select property= city >
<:option value= >北京市</:option>
<:option value= >广州市</:option>
<:option value= >上海市</:option>
</:select>
使用<:optionsCollection>标签
)在ActionForm中加入字段

private List cityList=new ArrayList();
)加入必须的getter方法
public List getCityList() {
return cityList;
}
)在reset方法内给cityList填充内容
cityList add(new LabelValueBean( 北京市 ));
cityList add(new LabelValueBean( 广州市 ));
cityList add(new LabelValueBean( 上海市 ));
)JSP标签中使用
<:select property= city >
<:optionsCollection property= cityList label= label value= value />
</:select>
使用<:options>标签
<%List cityList=new ArrayList();
cityList add(new LabelValueBean( 北京市 ));
cityList add(new LabelValueBean( 广州市 ));
cityList add(new LabelValueBean( 上海市 ));
request setAttribute( list cityList); //必须是request对象
%>
<:select property= city >
<:options collection= list labelProperty= label property= value />
lishixinzhi/Article/program/Java/ky/201311/28298