版权声明:此文章为许诗宇所写,如需转载,请写下转载文章的地址 https://blog.csdn.net/xushiyu1996818/article/details/82733656
只需要两个input的name相同,最后得到的就是一个 名称为name的value的数组
<td class="tb1_td5"><input id="min${status.index}" name="" style=" width:20px; height:18px;border:1px solid #ccc;" type="button" value="-" />
<input type="hidden" value="${product.id }" name="productId"/>
<input id="text_box${status.index}" name="num" type="text" value="${product.num }" style=" width:30px; text-align:center; border:1px solid #ccc;" />
<input id="add${status.index}" name="" style=" width:20px; height:18px;border:1px solid #ccc;" type="button" value="+" />
</td>
controller处理
@RequestMapping(value="/buyCart")
public ModelAndView buyCart(int[] productId,int[] num,
HttpServletRequest request, RedirectAttributes redirectAttributes){
int length=productId.length;
int total=0;