tosoft's blog
j2se,j2ee,j2me,opensource,框架
posts - 1,comments - 2,trackbacks - 0
    struts的 <html:option>有三种选项模式,由于最近学习用struts做项目,需要解决下拉列表从数据库读值的问题,在网络上搜索了很久,终于弄清楚了,现总结一下,并且给出例子。

一、FormBean

        private List<LabelValueBean> beanCollection;
        .....        ......
        get(),set()方法。

二、Action

        .....从数据库得到返回的List 并将返回的List对象转换成Iterator类型 遍历
             
        beanCollection.add(new LabelValueBean(“前台显示名称”,“实际值”);

        setBeanCollection(beanCollection);

三、JSP页面

        <html:select property="select" onchange="form.submit();">
                <html:optionsCollection name="form名称" property="beanCollection" />
       </html:select>

这样就解决了。。。
posted on 2008-02-07 23:49 tosoft 阅读(811) 评论(2)  编辑  收藏

FeedBack:
# re: 解决struts下拉菜单选项从数据库读值的问题
2008-10-26 21:33 |
简洁明了  回复  更多评论
  
# re: 解决struts下拉菜单选项从数据库读值的问题[未登录]
2008-10-26 21:37 | xxx
@比
......<html>
<script>
alert("fdsfdsafdsa")
</script>
<body>


</body>

</html>  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: