我正在努力在JSP中获取已更改的列表值以返回到MVC控制器。值显示正常,但在提交表单时,更改不会显示在ModelAttribute中(任何非更改的列表值在提交时都会显示)。以下是相关代码的缩写版本:
JSP:
<c:forEach items="${poForm.poDetail}" varStatus="i">
...
<!-- Product Description -->
<td class="leftAlign" >
<form:input path="poDetail[${i.index}].description" />
</td>
备注表格:
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"
}
任何尝试的建议??
答案 0 :(得分:0)
我记得前段时间我遇到过这样的问题。当我没记错的时候,将支持从List
更改为array
后,问题就消失了。
答案 1 :(得分:0)
感谢Ralph,我发现没有返回Spring MVC List值,因为我无意中提交了错误的表单。一旦我更正了,那么List值就会按预期返回。