2012-07-03 253 views
0

这个问题可能已经被问了数千次,但我无法得到这个工作。从数据库中填充下拉值

我需要填充页面加载时从数据库中的下拉值。我有一个域类表中被定义为“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中的下拉列表中打印这些值。任何帮助?

回答

0

你在哪里设置在mainform2属性的数据,你试图通过

items="${mainform2}" 
+0

不知道该怎么办呢 – Namita

+0

你写的'“$ {} mainform2.countryList”'你设置访问mainform2中属性'countryList'? –