Mysql的insert语句:
mybatis:foreach
Mybatis:批量插入环境搭建:
SysLog实体类:
SysLogMapper:
SysLogMapper.xml:
<insert id="insertLogs" parameterType="list">
insert into sys_log(
id,username,operatingTime,useTime,ip,url,method,requestType,title,businessType,returnArgs
)
VALUES
<foreach collection="sysLogs" item="sysLog" index="index" separator=",">
(
#{sysLog.id},
#{sysLog.username},
#{sysLog.operatingTime},
#{sysLog.useTime},
#{sysLog.ip},
#{sysLog.url},
#{sysLog.method},
#{sysLog.requestType},
#{sysLog.title},
#{sysLog.businessType},
#{sysLog.returnArgs}
)
foreach>
insert>