需求:成績錄入(錄入多門課成績,批量提交)
使用List接收頁面提交的批量數據,通過包裝pojo接收,在包裝pojo中定義list<pojo>屬性
public class ItemsQueryVo { //商品信息 private Items items; //為了系統 可擴展性,對原始生成的po進行擴展 private ItemsCustom itemsCustom; //批量商品信息 private List<ItemsCustom> itemsList; }
Controller:
// 批量修改商品提交 // 通過ItemsQueryVo接收批量提交的商品信息,將商品信息存儲到itemsQueryVo中itemsList屬性中。 @RequestMapping("/editItemsAllSubmit") public String editItemsAllSubmit(ItemsQueryVo itemsQueryVo) throws Exception { return "success"; }
頁面定義:
<c:forEach items="${itemsList }" var="item" varStatus="status"> <tr> <td><input name="itemsList[${status.index }].name" value="${item.name }"/></td> <td><input name="itemsList[${status.index }].price" value="${item.price }"/></td> <td><input name="itemsList[${status.index }].createtime" value="<fmt:formatDate value="${item.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/>"/></td> <td><input name="itemsList[${status.index }].detail" value="${item.detail }"/></td> </tr> </c:forEach>