http://hi.baidu.com/websays/blog/item/f702fa41d0ec001b9313c602.html
批处理的思想即是将所有的提交数据进行打包处理,进行提交的时候进行一次网络传输,减少网络负担,减少传输的时间。
1.页面上因为将同样的属性值设置成了与ACTION中对应的名称,所以从页面上得到的值是以STRING数组的形式传到ACTION的,这样就可以在ACTION中将这些数组进行处理。其中的CP_ID以及其他的信息也是同样的存储方式。为批处理带来便利。 2.具体的实现代码: try { SqlMapClient sqlmapclient =this.getSqlMapClient(); sqlmapclient.startBatch(); //批处理开始位置 Map map=new HashMap(); for(int i=0;i<array_cp_id.length;i++) { System.out.println(i+"---"+array_cp_id[i]+"---" +array_price[i]+"---" +array_jibie[i]); map.put("cp_id", array_cp_id[i].trim()); //为了将不必要的数据存入数据库使用TRIM map.put("price", array_price[i].trim()); map.put("jibie", array_jibie[i].trim()); this.getSqlMapClientTemplate().update("xmcymhy.savePL",map); } sqlmapclient.executeBatch(); //批处理执行位置 } catch (SQLException e) { e.printStackTrace(); } |
页面与action批量传值iBATIS批量更新
最新推荐文章于 2019-11-03 21:54:13 发布