zoukankan      html  css  js  c++  java
  • 多选删除

    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";
    	}
    

      

  • 相关阅读:
    【BestCoder #48】
    【一场模拟赛?】
    【普通の随笔】6.30
    【BestCoder #45】
    【BestCoder #44】
    【普通の惨败】GDOI2015卖萌记
    我的新博客
    【BZOJ 2964】Boss单挑战
    【NOI 2015】软件包管理器
    【NOI 2015】程序自动分析
  • 原文地址:https://www.cnblogs.com/menbo/p/9791794.html
Copyright © 2011-2022 走看看