欢迎在文章下方评论
###mybatis的拦截器实现分页(动态代理) 拦截sql语句来实现分页:
###具体过程
delete from
study_material
where
subject_id=#{subject.id} and web_id=#{webTitle.id}
and id in(
<foreach collection="idlist" item="item" separator=",">
#{item}
</foreach>
)
insert into
study_material(id,web_id,M_name,M_resource_url,M_upload_date,subject_id) values
<foreach collection="list" item="item" separator=",">
(#{item.id},#{item.webTitle.id},#{item.name},#{item.resourceUrl},#{item.uploadDate},#{item.subject.id})
</foreach>
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update test
<set>
test=${item.test}+1
</set>
where id = ${item.id}
</foreach>
如果User有属性List ids。入参是User对象,那么这个collection = “ids” 如果User有属性Ids ids;其中Ids是个对象,Ids有个属性List id;入参是User对象,那么collection = “ids.id” 上面只是举例,具体collection等于什么,就看你想对那个元素做循环。 该参数为必选。