定义一个用来显示的java bean比如:
public class OptionItem {
private String label;
private String value;
...
setter and getter method
...
}
然后把需要现实的放到这个类里面,然后放到FormBean一个属性集合里面,比如这个集合叫做 serverNameList,
<html:optionsCollection name="FtpmainForm" property="serverNameList" value="value" label="label"/>
这样就可以了
public class OptionItem {
private String label;
private String value;
...
setter and getter method
...
}
然后把需要现实的放到这个类里面,然后放到FormBean一个属性集合里面,比如这个集合叫做 serverNameList,
<html:optionsCollection name="FtpmainForm" property="serverNameList" value="value" label="label"/>
这样就可以了
解决方案 »
- 请问 在java中|这个字符如何读取出来
- MyEclipse6.5 与 JbossIDE for eclipse 2.2 哪个开发EJB3.0 更方便?
- hibernate annotation 生成timestamp的缺省的长度为6,怎么修改
- hibernate1对多双向映射配置问题
- 菜鸟提问web services,大家请帮帮忙哦!!!
- 请问一个以WEBLOGIC为应用服务器在JSP中使用CSS如何部署的问题.
- 〓〓〓〓〓〓〓 spring中事务应该设置在哪一层,哪一层需要接口? 〓〓〓〓〓〓
- 寻找JSP的可见即可得的ECLIPSE的插件.
- 怎么用java画出灰度或者是颜色渐变的图
- 关于三层结构的疑惑~
- log4j问题:如何让程序只执行一次装.properties
- executeBatch时 如何得到是哪些语句出错呢
前提是,给optionsCollection指定的List里面每个元素都是一个bean,
只要有相应的get方法。就拿“ Danken(科男)”的回复
<html:optionsCollection name="FtpmainForm" property="serverNameList" value="value" label="label"/>
只要form的serverNameList属性里面存放的是一个List,List里面的对象要有getValue()和getLabel方法,就不会有问题。补充一下只有这个optionsCollection 还不行,optionsCollection要放在<html:select property="selectdata"></html:select>里面。这样才是一个下拉框。
因为optionsCollection 只能生成html的option,没有select