【发布时间】: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 的下拉列表中打印这些值。有什么帮助吗?
【问题讨论】: