• springmvc中的批量删除语句和foreach的运用


    先贴一下代码

    先说一下springmvcc中的<forEach collection="array" index="index" item="id" open="(" separator="," close=")"></forEach>

    先来说一下这里面的各个属性

    collection代表是一个集合,如果你遍历的是一个数组那么就使用array,如果是List就使用list,这是框架定义好了的,

    index是指遍历的次数,相当与for循环中的i,

    item是别名,你可以任意写

    open和separator和close这个就用一个例子来说,比如你传入的数组是Integer[1,2,3,4,5],那么删除的sql语句是delete from 表名 where id in (1,2,3,4,5)在这里使用forEach我们是用in的

    第一种没有使用sql片段写的代码重用性差

    第二种是使用了sql片段的

    还有List和Map的我后面遇到了我再来更新!

  • 相关阅读:
    SGU 495 Kids and Prizes
    HDU 3853 LOOPS
    HDU 4089 Activation
    HDU 4405 Aeroplane chess
    ZOJ 3329 One Person Game
    POJ 2096 Collecting Bugs
    POJ1573(Robot Motion)
    poj2632(Crashing Robots)
    poj1068(Parencodings)
    poj2506(Tiling)
  • 原文地址:https://www.cnblogs.com/tranquilityMan/p/10972190.html
Copyright © 2020-2023  润新知