<html:select property="beanCollectionSelect" size="10" multiple="true">
<html:optionsCollection name="testbean" property="beanCollection"/>
</html:select>FORMname is testbeanprivate 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 optionsstruts 1.02不支持这个功能,要后续版本 1.1
具体可参考 www.apache.org 中的例子
解决方案 »
- 点击星星评分
- struts2的select标签,在我的编辑页面如何根据数据库中的值 选择成相应的值?
- j2ee jsp页面中显示问题
- 毕业大家一般都做什么呢??
- 十万火急.500 servlet exception 错误 改动了下resin文件夹出现的.请帮忙啊!
- 如何用STRUCT来实现将画面A中的一个ARRAYLIST对象传到画面B去
- strutsr validator中resource="false"不起作用
- 求大神指教 给HashMap还赋不上值了
- 关于struts
- BMP插入记录不能提交-100分
- 请那怎么样把1000000转成1,000,000呢。有效的一定给分。
- 用JB7.0+WEBLOJIC7.0 EJB控件问题
<html:select property="parentid">
<html:options collection="parentids" property="value" labelProperty="label"/> </html:select>就不知在actionfrom中如何定义?
页面optons交互的功能
只是与<html:select property="parentid">交互<html:options collection="parentids" property="value" labelProperty="label"/>上的collection 是jsp页面上 定义的建议你用上面我说的方法
<html:options name="answers" property="value" labelProperty="label"/>
</html:select>
出错:cannot find bean under name answers但在action form 中已定义了answers:
private Collection answers = null;
public Collection getAnswers() {
if (answers == null) {
Vector entries = new Vector(4);
entries.add(new labelvaluebean("Label1","Value1"));
entries.add(new labelvaluebean("Label1","Value1"));
entries.add(new labelvaluebean("Label2","Value2"));
entries.add(new labelvaluebean("Label3","Value3"));
answers = entries;
}
return (answers);
}
public void setAnswers(Collection answers) {
this.answers = answers;
}