当前位置: 技术问答>java相关
关于option的使用?
来源: 互联网 发布时间:2015-10-26
本文导语: 在Struts框架中,如何使用options? 例如:在jsp中这样写: 那在ActionForm中如何给这options赋值成类似: aaa bbb ccc 及如何取得用户选择的选项? | FORMname is testbean private String[] beanCollectionS...
在Struts框架中,如何使用options?
例如:在jsp中这样写:
那在ActionForm中如何给这options赋值成类似:
aaa
bbb
ccc
及如何取得用户选择的选项?
例如:在jsp中这样写:
那在ActionForm中如何给这options赋值成类似:
aaa
bbb
ccc
及如何取得用户选择的选项?
|
FORMname is testbean
private String[] beanCollectionSelect = { "Value 1", "Value 3",
"Value 5" };
public String[] getBeanCollectionSelect() {
return (this.beanCollectionSelect);}
public void setBeanCollectionSelect(String beanCollectionSelect[]) {
this.beanCollectionSelect = beanCollectionSelect;}
private Collection beanCollection = null;
public Collection getBeanCollection() {
if (beanCollection == null) {
Vector entries = new Vector(10);
entries.add(new LabelValueBean("Label 0", "Value 0"));
entries.add(new LabelValueBean("Label 1", "Value 1"));
entries.add(new LabelValueBean("Label 2", "Value 2"));
entries.add(new LabelValueBean("Label 3", "Value 3"));
entries.add(new LabelValueBean("Label 4", "Value 4"));
entries.add(new LabelValueBean("Label 5", "Value 5"));
entries.add(new LabelValueBean("Label 6", "Value 6"));
entries.add(new LabelValueBean("Label 7", "Value 7"));
entries.add(new LabelValueBean("Label 8", "Value 8"));
entries.add(new LabelValueBean("Label 9", "Value 9"));
beanCollection = entries;
}
return (beanCollection);
}
public void setBeanCollection(Collection beanCollection) {
this.beanCollection = beanCollection;
}
beanCollectionSelect 为 select 中 all selected options
beanCollection 为 select 中 all options
struts 1.02不支持这个功能,要后续版本 1.1
具体可参考 www.apache.org 中的例子