<!--==========================删除==================================== -->
<delete id="delete" parameterType="list">
<![CDATA[
delete t_vehicle_motorcade where fid in
]]>
<foreach collection="list" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
</delete>
DAO里面直接传入List参数即可:
@Override
public int delete(List<String> id) {
return getSqlSession().delete("VehicleMotorcade.delete",id);
}
页面(ExtJS):
xtype : ‘button‘,
text : ‘删除‘,
iconCls:‘icon-delete‘,
handler:function(){
//删除
var selectRecords = [];
selectRecords = getSelectRecord();
Ext.Ajax.request({
url: ‘motorcadeDelete.action‘,
params: {
‘selectRecords‘: selectRecords //selectRecords对应Action里面有个List的对象
},
success: function(response){
var text = Ext.decode(response.responseText);
Ext.Msg.alert(‘提示‘,text.message);
//刷新Grid,附带上查询条件
storeReload();
}
});
}
// 获取选定记录
function getSelectRecord(){
var records=motorcadeGrid.getSelectionModel().getSelection();
var ids = [];
for(var i=0; i<records.length; i+=1){
var member = records[i].get(‘id‘);
ids.push(member); //向数组后添加元素
}
return ids;
}