Java 将spring模型列表显示为简单字段
可以绑定字符串列表(List)并在组合框中的jsp中显示它们,如下所示:Java 将spring模型列表显示为简单字段,java,forms,spring,jsp,tags,Java,Forms,Spring,Jsp,Tags,可以绑定字符串列表(List)并在组合框中的jsp中显示它们,如下所示: <form:select path="countryId"> <form:option value="" label="Please Select"></form:option> <form:options items="${countryList}" itemValue="countryId" itemLabel="countryName"/> </f
<form:select path="countryId">
<form:option value="" label="Please Select"></form:option>
<form:options items="${countryList}" itemValue="countryId" itemLabel="countryName"/>
</form:select>
在JSP中,我使用
<c:forEach var="OutputsList" items="${Outputs}">
${OutputsList}
</c:forEach>
${OutputsList}
但这份名单并没有打印出来。原因可能是什么?那样做
<c:forEach var="country" items="${countryList}">
<tr>
<td>${country.countryId}</td>
<td>${country.countryName}</td>
</tr>
</c:forEach>
${country.countryId}
${country.countryName}
在服务器端使用ModelAndView对象
List<Country> countryList;
ModelAndView mv = new ModelAndView("index");
mv.addObject("country",countryList);
List countryList;
ModelAndView mv=新的ModelAndView(“索引”);
mv.addObject(“国家”,国家列表);
那样做
<c:forEach var="country" items="${countryList}">
<tr>
<td>${country.countryId}</td>
<td>${country.countryName}</td>
</tr>
</c:forEach>
${country.countryId}
${country.countryName}
在服务器端使用ModelAndView对象
List<Country> countryList;
ModelAndView mv = new ModelAndView("index");
mv.addObject("country",countryList);
List countryList;
ModelAndView mv=新的ModelAndView(“索引”);
mv.addObject(“国家”,国家列表);
在jsp中使用它时出现了错误的方法。从所讨论的代码中,只需交换输出列表
Map referenceData = new HashMap();
referenceData.put("OutputsList", Outputs);
在JSP中,我使用
<c:forEach var="OutputsList" items="${Outputs}">
${OutputsList}
</c:forEach>
${item}
它将起作用。在jsp中使用它时出现了错误的方法。从所讨论的代码中,只需交换输出列表
Map referenceData = new HashMap();
referenceData.put("OutputsList", Outputs);
在JSP中,我使用
<c:forEach var="OutputsList" items="${Outputs}">
${OutputsList}
</c:forEach>
${item}
会有用的。谢谢回复。我修改了我的问题。请再看一次,谢谢回复。我修改了我的问题。请再看一次。