<!-- 删除一条 --> <delete id="deleteById" parameterType="string"> delete from factory_c where FACTORY_ID=#{id} </delete> <!-- 删除多条(一维字符串数组的形式) --> <delete id="delete" parameterType="string"> delete from factory_c where FACTORY_ID in <foreach collection="array" item="id" open="(" close=")" separator=","> #{id} </foreach> </delete>
public void deleteById(Serializable id) { this.getSqlSession().delete(ns + ".deleteById", id); } public void delete(Serializable[] ids) { this.getSqlSession().delete(ns + ".delete", ids); }
@Override public void delete(Serializable[] ids) { factoryDao.delete(ids); } @Override public void deleteById(Serializable id) { factoryDao.deleteById(id); }
//删除一个 @RequestMapping("/basicinfo/factory/deleteById.action") public String deleteById(String id){ factoryService.deleteById(id); return "redirect:/basicinfo/factory/list.action"; } //删除多条 @RequestMapping("/basicinfo/factory/delete.action") public String delete(@RequestParam("id") String[] ids){ factoryService.delete(ids); return "redirect:/basicinfo/factory/list.action"; }
<li id="delete"><a href="#" onclick="formSubmit('deleteById.action','_self');this.blur();">删除</a></li> <li id="delete"><a href="#" onclick="formSubmit('delete.action','_self');this.blur();">删除N</a></li>
然后点击“删除N”,然后选择多个进行删除
<!-- 查询一个 --> <select id="get" parameterType="string" resultMap="factoryRM"> select * from factory_c where factory_id=#{id} </select> 然后我们的dao层由于继承了BaseDaoImpl,所以自然包含了下面这个方法 public T get(Serializable id) { return this.getSqlSession().selectOne(ns + ".get", id); }
@Override public Factory get(Serializable id) { return factoryDao.get(id); }
//查看 @RequestMapping("/basicinfo/factory/toview.action") public String toview(String id,Model model){ Factory obj=factoryService.get(id); model.addAttribute("obj",obj); return "/baseinfo/factory/jFactoryView.jsp"; }
<%@ page language="java" pageEncoding="UTF-8"%> <%@ include file="../../base.jsp"%> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>查看厂家信息</title> </head> <body> <form method="post"> <div id="menubar"> <div id="middleMenubar"> <div id="innerMenubar"> <div id="navMenubar"> <ul> <li id="back"><a href="list.action">返回</a></li> </ul> </div> </div> </div> </div> <div class="textbox" id="centerTextbox"> <div class="textbox-header"> <div class="textbox-inner-header"> <div class="textbox-title"> 查看生产厂家信息 </div> </div> </div> <div> <div> <table class="commonTable" cellspacing="1"> <tr> <td class="columnTitle_mustbe">厂家名称:</td> <td class="tableContent">${obj.fullName }</td> <td class="columnTitle_mustbe">简称:</td> <td class="tableContent">${obj.factoryName }</td> </tr> <tr> <td class="columnTitle_mustbe">联系人:</td> <td class="tableContent">${obj.contacts }</td> <td class="columnTitle_mustbe">电话:</td> <td class="tableContent">${obj.phone }</td> </tr> <tr> <td class="columnTitle_mustbe">手机:</td> <td class="tableContent">${obj.mobile }</td> <td class="columnTitle_mustbe">传真:</td> <td class="tableContent">${obj.fax }</td> </tr> <tr> <td class="columnTitle_mustbe">检验员:</td> <td class="tableContent">${obj.inspector }</td> <td class="columnTitle_mustbe">排序号:</td> <td class="tableContent">${obj.orderNo }</td> </tr> <tr> <td class="columnTitle_mustbe">备注:</td> <td class="tableContent">${obj.cnote }</td> </tr> </table> </div> </div> </form> </body> </html>
<li id="view"><a href="#" onclick="formSubmit('toview.action','_self');this.blur();">查看</a></li>
查询结果
转载请注明出处:http://blog.csdn.net/acmman/article/details/48318689