我正在将自定义对象传递给jsp。牢记此自定义类将列表作为字段,如何将输入标签绑定到它? JSP表单:
<f:form method="POST" action="${url_save}" modelAttribute="sprav">
<tr>
<c:forEach var="columnName" items="${sprav.columnName}">
<td><f:input path="${columnName}"></f:input></td>
</c:forEach>
</tr>
</f:form>
我的自定义类:
public class Spravochnik extends BaseEntity {
private List<String> columnName;
private List<List<String>> valuesInRows;
public List<String> getColumnName() {
return columnName;
}
public void setColumnName(List<String> columnName) {
this.columnName = columnName;
}
public List<List<String>> getValuesInRows() {
return valuesInRows;
}
public void setValuesInRows(List<List<String>> valuesInRows) {
this.valuesInRows = valuesInRows;
}
}
BaseEntity仅具有ID
我的控制器:
@RequestMapping(value = "/edit", method = { RequestMethod.POST, RequestMethod.GET })
public ModelAndView edit(@RequestParam("id") String id, ModelMap model) {
Spravochnik sprav = spravochnikService.selectOne(id);
model.addAttribute("sprav", sprav);
return new ModelAndView("edit", model);
}