1.前台页面
<script type="text/javascript"> function isShow(pageNo,name,brandId,isShow) { if(Pn.checkedCount('ids')<=0) { alert("请至少选择一个!"); return; } if(!confirm("确定上架吗?")) { return; } $("#jvForm").attr("action","isShow.do?pageNo="+pageNo+"&name="+name+"&brandId="+brandId+"&isShow="+isShow); //jquery方式 $("#jvForm").submit(); } </script>
<form method="post" id="jvForm"> <!-- <input type="hidden" value="" name="pageNo"/> <input type="hidden" value="" name="queryName"/> --> <table cellspacing="1" cellpadding="0" width="100%" border="0" class="pn-ltable"> <thead class="pn-lthead"> <tr> <th width="20"><input type="checkbox" onclick="Pn.checkbox('ids',this.checked)"/></th> <th>商品编号</th> <th>商品名称</th> <th>图片</th> <th width="4%">新品</th> <th width="4%">热卖</th> <th width="4%">推荐</th> <th width="4%">上下架</th> <th width="12%">操作选项</th> </tr> </thead> <tbody class="pn-ltbody"> <c:forEach items="${pagniation.list }" var="entry"> <tr bgcolor="#ffffff" onmouseover="this.bgColor='#eeeeee'" onmouseout="this.bgColor='#ffffff'"> <td><input type="checkbox" name="ids" value="${entry.id }"/></td> <td>${entry.id }--${entry.no }</td> <td align="center">${entry.name }</td> <td align="center"><img width="50" height="50" src="${entry.img.allUrl }"/></td> <td align="center">是</td> <td align="center">是</td> <td align="center">是</td> <td align="center"> <c:if test="${entry.isShow==0 }">下架</c:if> <c:if test="${entry.isShow==1 }" >上架</c:if> </td> <td align="center"> <a href="#" class="pn-opt">查看</a> | <a href="#" class="pn-opt">修改</a> | <a href="#" onclick="if(!confirm('您确定删除吗?')) {return false;}" class="pn-opt">删除</a> | <a href="../sku/list.jsp" class="pn-opt">库存</a> </td> </tr> </c:forEach> </tbody> </table> <div class="page pb15"><span class="r inb_a page_b"> <span class="r inb_a page_b"> <c:forEach items="${pagniation.pageView}" var="page"> ${page } </c:forEach> </span> </div> <div style="margin-top:15px;"><input class="del-button" type="button" value="删除" onclick="optDelete();"/><input class="add" type="button" value="上架" onclick="isShow('${pagniation.pageNo }','${name}','${brandId }','${isShow }');"/><input class="del-button" type="button" value="下架" onclick="optDelete();"/></div> </form>
2.controller层
@RequestMapping(value="/product/isShow.do") public String isShow(Integer[]ids,Integer pageNo,String name ,Integer brandId ,Integer isShow ,ModelMap model){ Product product = new Product(); product.setIsShow(1); if(null!=ids&& ids.length>0){ for(Integer id:ids){ product.setId(id); productService.updateProductByKey(product);//修改上架状态 } } if(null!=pageNo){ model.addAttribute("pageNo",pageNo); } if(null!=name){ model.addAttribute("name",name); } if(null!=brandId){ model.addAttribute("brandId",brandId); } if(isShow!=null){ model.addAttribute("isShow",isShow); } return "redirect:/product/list.do"; }