标签没用对吧,我的方法是吧几个选项放在collection中。例如:
<html:select property="beanCollectionSelect">
<html:optionsCollection name="testForm"
property="beanCollection"/>
</html:select>beanCollectionSelect是form里string型的属性,代表所选项
beanCollection是form里Collection型熟悉,代表供选择的选项集合
beanCollection这样赋值:
Vector entries = new Vector(10);
entries.add(new LabelValueBean(“Delivery”,“a”));
entries.add(new LabelValueBean(“Pickup”,“b”));
beanCollection=entries;
这样,beanCollectionSelect的值就是“a”或“b”应该是解决你的问题的一种方法
<html:select property="beanCollectionSelect">
<html:optionsCollection name="testForm"
property="beanCollection"/>
</html:select>beanCollectionSelect是form里string型的属性,代表所选项
beanCollection是form里Collection型熟悉,代表供选择的选项集合
beanCollection这样赋值:
Vector entries = new Vector(10);
entries.add(new LabelValueBean(“Delivery”,“a”));
entries.add(new LabelValueBean(“Pickup”,“b”));
beanCollection=entries;
这样,beanCollectionSelect的值就是“a”或“b”应该是解决你的问题的一种方法
解决方案 »
- 通过myeclipse中发布到tomcat中运行没有问题,达成war包部署就出错
- jdbc连接SQLServer 失败 !
- Myeclipse安装的时候出错,郁闷~
- 收藏 不显示删除回复显示所有回复显示星级回复显示得分回复 <s:password>在用ajax验证后会返回一个默认值的问题
- J2EE标准的制定有哪些公司参与了制定
- 点击链接执行某函数问题,高手进来帮帮忙,谢谢了
- 学习WEB SERVICES
- Help! Spring+Hibernate应用中的错误
- Java使用JDBC操作Oracle数据库遇到的两个问题,求解
- 好象在xml专栏或java专栏都可以问这个问题-xml、jsp高手请进
- 最后100分!!!!!!!!!Struts1.1的validators frameword如何使服务器端验证生效?
- 有没有关于struts的中文电子图书?
这种写法就是说默认从formbean里去取东西.那么你这个语句就必须包含在
<html:form >和</html:form >之间
我们可以自定义一个javabean,它包含这两个属性,也可以用struts提供的ValueLabelBean;当我们在程序里对数据库里某张表进行查询后得到一个ResultSet,
我们一般会对这个ResultSet中的数据进行提取,并把它们保存到上面提到的javaben或ValueLabelBean里;并形成一个类似Vector 或Collection的对象;
然后,我们把这个Vector或Collection放到request里,如:
request.setAttribute ("myVector", myVector);然后,返回jsp,
在jsp里使用:
<html:select name="YourFormName" property="yourCurrentValue">
<html:options collection ="myVector" property="yourValue" labelProperty="yourLabel"/>
</html:select>这样,struts就会正确显示你当前使用的value值,并在下拉框里显示对应的值。
不过,一般常会犯这样的错误,
也就是你要注意,
yourCurrentValue要在yourValue里存在,,,,
ok?