对于批量数据的删除,官方demov3版本没有找到,为了梳理一下,特此记录
用代码生成器生成的controller中没有关于批量删除的方法,所以要我们自己写。
这里首先要在Controller类中增加批量删除的方法:
/**
* 全选删除Demo
*
* @return
* @author tanghan
* @date 2013-07-13 14:53:00
*/
@RequestMapping(params = "doDeleteALLSelect")
@ResponseBody
public AjaxJson doDeleteALLSelect(UnitInfoEntity unitInfo, HttpServletRequest request) {
AjaxJson j = new AjaxJson();
String ids = request.getParameter("ids");
String[] entitys = ids.split(",");
List<UnitInfoEntity> list = new ArrayList<UnitInfoEntity>();
for(int i=0;i<entitys.length;i++){
unitInfo = systemService.getEntity(UnitInfoEntity.class, entitys[i]);
list.add(unitInfo);
}
message = "批量删除成功";
unitInfoService.deleteAllEntitie(list);
systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
j.setMsg(message);
return j;
然后在list页面添加删除按钮:
<t:dgToolBar title="批量删除" icon="icon-remove" url="unitInfoController.do?doDeleteALLSelect" funname="deleteALLSelect"></t:dgToolBar>
运行程序页面效果:
点击确定: