在struts1.2中如何根据数据库值填充下拉列表 [英] In struts1.2 how to populate dropdown according to database value

查看:88
本文介绍了在struts1.2中如何根据数据库值填充下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框和一个关于html的下拉列表,单击保存按钮后其值将保存到数据库中,但是在搜索该值时,除下面的下拉列表外,所有文本框和单选按钮均已填充..

I have a textboxes and one dropdown on html whose value is getting saved to database on clicking save button but on searching for the value all textboxes and radio button are getting populated except the foloowing dropdown ..

      <td align= "right" nowrap> 
                            <html:select property="standard">

                                <html:option value="I">I</html:option>

                                <html:option value="II">II</html:option>

                                <html:option value="III">III</html:option> ...

并使用以下代码填充值.

and for populating the values i am using th following code..

        stuform.setStandard((String)tempmap.get("STANDARD"));

注意:我已经检查了stuform.getStandard()值,但未在jsp上显示.

Note: I have checked stuform.getStandard() value is there but it is not getting displayed on jsp.

推荐答案

下拉列表应由表单类中的LabelValueBean对象的列表表示,如下所示.

The dropdown list should be represented by a list of LabelValueBean objects in your form class as follows.

List<LabelValueBean> listOfStandards = new ArrayList<LabelValueBean>();
//popoulate the list
myForm.setStandardList(listOfStandards);

在jsp中,您可以按以下方式访问下拉列表中的列表:

And in your jsp you can access the list in your drop down list as follows:

<html:select property="standard" styleId="standard">
    <html:optionsCollection name="myForm" property="standardList" label="label" value="value"  />
</html:select>

注意:确保表单中具有标准"属性.将使用下拉列表中所选项目的值设置标准"属性.

Note: Make sure you have a "standard" property in your form. The "standard" property will be set with the value of the selected item from the dropdown list.

这篇关于在struts1.2中如何根据数据库值填充下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆