【问题标题】:populating drop down values from the database从数据库中填充下拉值
【发布时间】:2012-07-03 16:18:32
【问题描述】:

这个问题可能已经被问了数千次,但我无法解决这个问题。

当页面加载时,我需要从数据库中填充下拉值。我有一个域类表定义为 "CountryList"

我正在获取所有国家/地区的列表

@RenderMapping(params = "action=studentPage")

    public String studentSetUpPage(RenderRequest request,
                RenderResponse response, ModelMap model) {


// some code

ArrayList<CountryList> getAllCountries = serviceClass.getAllCountries(id);

for(CountryList country : getAllCountries){

    System.out.println(" Country " + listCountry.getCountry());

}


}

JSP 代码

<form action="<%=save%>" method="POST" name="createpage"                                            id="createPage">

<table>
    <c:forEach var="mainform1" items="${mainform2}">

<aui:select name="countrySelect" id="countrySelect"
          label="Country :" inlineLabel="Country:"
          showRequiredLabel="false">

          <c:forEach var="countryList"
            items="${mainform2.countryList}">
         <aui:option label="....."
         value="..........">
         </aui:option>
         </c:forEach>

</aui:select>

</c:forEach>
</table>
</form>

它在控制台上打印所有国家。

我想在 jsp 的下拉列表中打印这些值。有什么帮助吗?

【问题讨论】:

    标签: java jsp yui


    【解决方案1】:

    您在哪里设置了mainform2 属性中的数据,并且您尝试通过以下方式访问它

    items="${mainform2}"
    

    【讨论】:

    • 你写了"${mainform2.countryList}" 有没有在mainform2 中设置countryList 属性?
    猜你喜欢
    • 1970-01-01
    • 2016-01-09
    • 1970-01-01
    • 1970-01-01
    • 2011-11-09
    • 2014-12-25
    相关资源
    最近更新 更多