1、MyBatis中sql参数为list的动态sql语句;
WHERE ST.CLASS_ID IN
<foreach collection="list" item="classIdList" open="(" separator="," close=")">
#{classIdList}
</foreach>
<select id="getAppValidates" parameterType="app" resultType="App_validate">
SELECT * FROM user_app_validate WHERE app_package_name IN
<foreach collection="array" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
WHERE ST.CLASS_ID IN
<foreach collection="list" item="classIdList" open="(" separator="," close=")">
#{classIdList}
</foreach>
<select id="getAppValidates" parameterType="app" resultType="App_validate">
SELECT * FROM user_app_validate WHERE app_package_name IN
<foreach collection="array" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
2、MyBatis中处理特殊字符问题;
< < 小于号
<![CDATA[ when min(starttime)<='12:00' and max(endtime)<='12:00' ]]>
3、在Mybatis中传入多个参数;
@Param("offset") int offset, @Param("limit") int limit,@Param("str") String str;
直接在接口里面定义参数;
4、Mybatis中的转义字符
< < 小于号
> > 大于号
& & 和
' ' 单引号
" " 双引号