collection :collection属性的值有三个分别是list、array、map三种,分别对应的参数类型为:List、数组、map集合,我在上面传的参数为数组,所以值为array
item : 表示在迭代过程中每一个元素的别名
index :表示在迭代过程中每次迭代到的位置(下标)
open :前缀
close :后缀
separator :分隔符,表示迭代时每个元素之间以什么分隔
@Delete("<script>" +
"delete from product" +
"<where>" +
"id in"+
"<foreach item='pid' collection='array' separator=',' open='(' close=')' index=''>"
+"#{pid, jdbcType=VARCHAR}"
+"</foreach>"
+ "</where>"
+ "</script>")
public int deleteByIds(String[] ids);
前端JSP页面向后端传值
function f1(){ //jquery获取复选框值
var chk_value =[];
$('input[name="ids"]:checked').each(function(){
chk_value.push($(this).val());
});
//alert(chk_value.length==0 ?'你还没有选择任何内容!':chk_value); delete.do
location.href = "${pageContext.request.contextPath}/product/delete.do?ids="+chk_value;
}
按钮
<button type="button" id="btn btn-default" class="btn btn-default" title="删除" onclick="f1()">