后台遍历数组id查询数据

在xml遍历数组id

//前端获取对应的id并存到数组里面
       function printSerialNumber() {
            var arr = new Array();
            if ($(".unclaimedId:checked").length == 0) {
                $.jBox.alert('请至少选择一条数据打印');
                return false;
            } else {
                //获取需要打印的数据
                $(".unclaimedId:checked").each(function () {
                    if ($(this).attr("checked") == "checked") {
                        arr.push($(this).val());
                    }
                });
                var url = "${ctx}/bz/unclaimed/printSerialNumber?ids=" + arr;
                window.open(url);
            }
        }

//通过CheckBox获取对应的id
 <th><input type="checkbox" id="checkAll" style="display: inline-block; width:20px;height: 20px;"></th>
 
 <input name="input_id" class="unclaimedId" type="checkbox" value="${bzDeceased.id}" style="display: inline-block; width:20px;height: 20px;">

 // 点击全部选中/取消选中
$("#checkAll").click(function () {
  $(".unclaimedId").attr("checked", this.checked);
addGhMap();
});

//BzListGroup 实体类定义一个数组接收前台传来数组id
private String[] projectArr;



//controller接收值前端传过来的数组id
 public String printSettled(BzListGroup bzListGroup, Model model) {




//xml实体类内的数组遍历:
<if test="projectArr != null and projectArr.length > 0">
    and blg.id in
    <foreach collection="projectArr" separator="," item="id" open="(" close=")">
        #{id}
    </foreach>
</if>

在service遍历数组id

service层

  List<BzUnclaimedClearance> list1 = new ArrayList<>();
        try {
            if (ids != null && ids.length > 0) {
                List<String> list = Arrays.asList(ids);//该方法是将数组转化成list集合
                list1 = dao.printSettlementDetails(list);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list1;
    }

xml文件遍历数组id
   <if test="list.size()>0">
            blg.id in
            <foreach collection="list" separator="," item="id" open="(" close=")">
                #{id}
            </foreach>
        </if>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Java中的战斗机

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值