我很努力地在JSP中获取已更改的列表值以返回到MVC控制器。值显示正常,但在提交表单时(在提交时显示更改的任何非列表值),更改不会显示在ModelAttribute中。下面是相关代码的缩写版本:Spring MVC列表值返回不变
JSP:
<c:forEach items="${poForm.poDetail}" varStatus="i">
...
<!-- Product Description -->
<td class="leftAlign" >
<form:input path="poDetail[${i.index}].description" />
</td>
打底FORM:
public class POForm {
private List<PurchaseOrderDetail> poDetail;
...
}
PURCHASEORDERDETAIL:
public class PurchaseOrderDetail implements Comparable<PurchaseOrderDetail>{
private String partNumber; // alpha-numeric part number (vendor's)
private String description; // Product name/description
... remaining properties are non-complex
}
控制器:
@RequestMapping(value="/savePO",method=RequestMethod.POST)
public ModelAndView savePO(@ModelAttribute("poForm") POForm poForm, final
HttpServletRequest request) {
.... "examine the poForm here and items of poDetail are unchanged"
}
任何建议尝试?
您是否拥有poDetail和description属性的setter和getter? – xyz
是的。我没有将它们包含在代码中以保持简单。 – Mike
在这个控制器中是否有任何其他的@ModelAttribute注释方法 - 它必须从某个地方检索旧值 –