时间:2022-11-08 09:50:52 | 栏目:JAVA代码 | 点击:次
<!--concat Mysql和 Oracle区别 ,不存在sql注入--> <select id="findUserByLikeName3" parameterType="java.lang.String" resultMap="user"> select * from t_user where name like concat('%',#{name,jdbcType=VARCHAR},'%') </select>
mysql 的 like,建议 like concat() 组合,可以防止sql注入
<select id="selectLogininforList" parameterType="SysLogininfor" resultMap="SysLogininforResult"> select info_id,login_name,ipaddr,login_location,browser,os,status,msg,login_time from sys_logininfor <where> <if test="ipaddr != null and ipaddr != ''"> AND ipaddr like concat('%', #{ipaddr}, '%') </if> <if test="status != null and status != ''"> AND status = #{status} </if> <if test="loginName != null and loginName != ''"> AND login_name like concat('%', #{loginName}, '%') </if> <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> and date_format(login_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') </if> <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> and date_format(login_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') </if> </where> </select>