menbbo

导航

 

1.jsp页面

<script type="text/javascript">
      function checkBox(name,checked){
    	  $("input[name='"+ name +"']").attr("checked",checked); //全选
      }
      
      function optDelete(name,isDisplay){
    	var s = $("input[name='ids']:checked").size();  //选中的个数
        if(s<=0){
        	alert("请至少选择一个");
        }
    	if(!confirm("你确定删除吗?")){
    		return;
    	}
    	$("#jvForm").attr("action","/brand/deletes.do?name="+name+"&disPlay="+isDisplay);
    	$("#jvForm").attr("method","post").submit(); 
      }
</script>

  

<form id="jvForm">
<table cellspacing="1" cellpadding="0" border="0" width="100%" class="pn-ltable">
	<thead class="pn-lthead">
		<tr>
			<th width="20"><input type="checkbox" onclick="checkBox('ids',this.checked)"/></th>
			<th>品牌ID</th>
			<th>品牌名称</th>
			<th>品牌图片</th>
			<th>品牌描述</th>
			<th>排序</th>
			<th>是否可用</th>
			<th>操作选项</th>
		</tr>
	</thead>
	<tbody class="pn-ltbody">
		<c:forEach items="${pagination.list }" var="entry">		
			<tr bgcolor="#ffffff" onmouseout="this.bgColor='#ffffff'" onmouseover="this.bgColor='#eeeeee'">
				<td><input type="checkbox" value="${entry.id }" name="ids"/></td>
				<td align="center">${entry.id }</td>
				<td align="center">${entry.name }</td>
				<td align="center"><img width="40" height="40" src="${entry.allUrl}"/></td>
				<td align="center">${entry.description }</td>
				<td align="center">${entry.sort }</td>
				<td align="center"><c:if test="${entry.isDisplay == 1 }">是</c:if><c:if test="${entry.isDisplay == 0 }">不是</c:if></td>
				<td align="center">
				<a class="pn-opt" href="javascript:void(0)" onclick="window.location.href='/brand/toEdit.do?id=${entry.id}'">修改</a> | <a class="pn-opt"  onclick="if(!confirm('确定要删除吗?')) {return false;}  window.location.href='/brand/delete.do?id=${entry.id }&name=${name}&isDisplay=${isDisplay}'" href="javascript:void(0)">删除</a>
				</td>
			</tr>
		</c:forEach>
	
	</tbody>
</table>
</form>

  2.BrandDao.xml文件:

<delete id="deleteBrandByKeys" parameterType="Integer">
	    delete from bbs_brand
	    <where>
	      id in
	      <foreach collection="array" item="id" open="(" close=")" separator=",">
	         #{id}
	      </foreach>
	    </where>
</delete>

  3.BrandDao.java:

public interface BrandDao {
     public List<Brand> getBrandListWithPage(Brand brand);
     //删除选中
     public void deleteBrandByKeys(Integer []ids);
}

3.BrandService与BrandServiceImpl略

4.controller层

	
	@RequestMapping(value="/brand/deletes.do")
	public String deletes(Integer[] ids,String name,Integer isDisplay,ModelMap model){
		//TODO 删除
				brandService.deleteBrandByKeys(ids);
				if(StringUtils.isNotBlank(name)){
					model.addAttribute("name", name);
				}
				if(null != isDisplay){
					model.addAttribute("isDisplay", isDisplay);
				}
				return "redirect:/brand/list.do";
	}

  

 

posted on 2018-10-15 16:35  menbbo  阅读(260)  评论(0编辑  收藏  举报